Unary and Binary Operators in the Model Object
The table below describes the unary and binary operators that can be used when accessing a model object, such as the model expressions used when defining parameters, variables, material properties, and boundary conditions, as well as in expressions used in results for postprocessing and visualization.
Precedence Level
Symbol
Description
1
() {} .
grouping, lists, scope
2
^
power
3
! - +
unary: logical not, minus, plus
4
[]
unit
5
* /
binary: multiplication, division
6
+ -
binary: addition, subtraction
7
< <= > >=
comparisons: less-than, less-than or equal, greater-than, greater-than or equal
8
== !=
comparisons: equal, not equal
9
&&
logical and
10
||
logical or
11
,
element separator in lists
The following example code creates a variable to indicate whether the effective von Mises stress exceeds 200 MPa by using the inequality
solid.mises>200[MPa]
:
model.variable().create("var1");
model.variable("var1").model("comp1");
model.variable("var1").set("hi_stress", "solid.mises>200[MPa]");
The following code demonstrates using this variable in a surface plot:
model.result().create("pg3", "PlotGroup3D");
model.result("pg3").create("surf1", "Surface");
with(model.result("pg3").feature("surf1"));
set("expr", "hi_stress");
endwith();
model.result("pg3").run();
The same plot can be created by directly using the inequality expression in the surface plot expression as follows:
with(model.result("pg3").feature("surf1"));
set("expr", "solid.mises > 200[MPa]");
endwith();
model.result("pg3").run();