
Applies To | |
Product(s): | OpenPlant PowerPID; OpenPlant Modeler |
Version(s): | * |
Environment: | N/A |
Area: | Class Editor |
Subarea: | |
Original Author: | Justinas Lipnickas, Bentley Technical Support Group |
Overview
An ECExpression is a text string that defines syntax to be evaluated by the ECExpression evaluator. The ECExpressions expression evaluator provides a simple interface for retrieving values from ECInstances. The expression input to the evaluator is comprised of numbers, strings, access strings, symbols, and operators. The syntax for ECExpressions expressions is similar to the syntax for VB.Net expressions.
Expression components
- String - "Dog"
- Integer - 1
- Double - 6.84
- Symbol - Symbols can be used to supply values to expression evaluator. Symbols can be from an ECInstance via an access string, from an application defined value, or from an application defined method:
- ECInstance - "ActiveFile.Author" Note-An access string is a limited expression that contains no blanks, no operators and no variable portions.
- Value - "System.Math.PI"
- Method - "System.Math.Sin(1.57)"
- Operators
- Comparison <, <=, >, >=, =, and <>
- Conditional IIf (conditional,true-result,false-result)
- Arithmetic ^ (exponentiation), *, /, \, Mod, +, and -. The division operator "/" always produces a result of type double. The division operator "\" always produces an integer result.
Simple Expression Examples
String Concatenation
- 1 & "4" -> "14"
- "Dog" & " and " & "Cat" -> "Dog and Cat"
Arithmetic
- 1 + "4" -> 5
- 2.3 * 3 -> 6.9
- 12/5 -> 2.4
- 12\5 -> 2
- 25 mod 3 -> 1
Comparison
Conditional
- IIf (500>200,"math ok", "math wrong") -> "math ok"
- IIf (500<200,"math ok", "math wrong") -> "math wrong"
Traversing ECRelationships
this.GetRelatedInstance({ECRelationshipClass}:{DirectionIndicator}:{Related ECClass})
where "DirectionIndicator" is 0 for "forward" and 1 for "backward"
For example, to traverse from an instance of Foo to an instance of Boo using the FooHasBoo relationship, and access property B:
this.GetRelatedInstance("FooHasBoo:0:Boo").B
To traverse from an instance of Boo to and instance of Foo using the "backward" direction of the FooHasBoo relationship, and access property F:
this.GetRelatedInstance("FooHasBoo:1:Foo").F
Combined expressions
- System.Math.Cos(System.Math.PI*45.0/180.0) -> 0.707
- System.String.Length("Dog" & " and " & "Cat") -> 11
- System.String.ToLower(System.Environment.GetEnvironmentVariable("USERDOMAIN")) -> bentley
Operators for Null with Property null
- IfNull(this.Property, "") -> ""
- IIf (Not IsNull(this.Property)," " & this.Property & " ", "") -> ""
Required ECExpression SymbolSets
When using any of the System functions in the calculated expressions the Required ECExpression SymbolSets needs to be added. Please see the snapshot for additional information on this:

See Also
Functions, which are generally available in the System classes can be reviewed at MSDN website: