Expressions

Motion Analyst entities support expressions.

You can create two types of expressions:
  • Parametric expressions
  • Solver expressions
Both types are evaluated through Templex, a text and numeric parser.

Entry fields for Motion Analyst entities, such as points, bodies, bushings, spring-dampers, forces, and others, can contain expressions. These fields are available in the Property Editor, guide panels, or microdialogs, and are often marked with a curly bracket icon .

Parametric Expressions

Parametric expressions are used to relate the value of one modeling entity to another within the model.

The data type returned by a parametric expression must match the data type of the field it defines.

You can also use the mathematical operators and functions available in the Templex text and numeric language when creating parametric expressions.

Parametric expressions are supported in entry fields of type Constant and Expression.

Note: Entry fields containing a parametric expression are marked with a small blue triangle in the upper-left corner.
Figure 1. Typing (left) vs. Solved (right)


Warning: If Inspire cannot evaluate an expression or the parametric expression returns an incorrect data type, an Error Evaluating message appears in the entry field.
Figure 2. Typing (left) vs. Error (right)


Example

Consider two points in a model with variable names Point_1 and Point_2. To position Point_2 so that its X location is 10 units away from the X location of Point_1, you can use a parametric expression.

The parametric value of the X coordinate for Point_1 is represented by the data member x, which is accessed using the expression Point_1.x. Therefore, to place Point_2 10 units from the X location of Point_1, enter the following expression in the X coordinate field of Point_2:

Point_1.x + 10

This ensures that Point_2 is positioned parametrically relative to Point_1, maintaining a consistent offset even if Point_1 moves.

Figure 3. Point_1 (left) and Point_2 (right) Microdialogs


Solver Expressions

Solver expressions define linear or nonlinear values that depend on time or solver state for entities such as bushings, spring-dampers, force vectors, and motions.

These expressions might combine unevaluated strings with evaluated parametric expressions.

During runtime, Inspire converts solver expressions into functions compatible with the solver.

Solver expressions are supported in entry fields of type Expression only.

Follow these rules to write solver expressions:

  • Enclose the entire solver expression in back quotes `…`.
  • Enclose parametric expressions inside the solver expression in curly brackets {…}.
Note: Any parametric expressions inside curly brackets are first evaluated by the Templex parser and replaced with their resulting values before the solver expression is sent to the solver. Expression components outside the curly brackets are passed directly to the solver without evaluation.
Warning: If the solver expression is not enclosed in back quotes, Inspire evaluates the entire expression using the Templex parser, which usually results in an error.

Example

Consider a force whose magnitude ramps from zero at 1 s to 500 times the distance between two markers at 1.5 s using a step function. You can define this nonlinear value using the following solver expression:

`STEP( TIME, 1, 0, 1.5, 500*DX( {Marker_1.idstring} , {Marker_2.idstring} ) )`

According to the rules for evaluating solver expressions, Inspire first evaluates Templex values within curly brackets, ignoring all other text in the function. In this example, the parametric variables Marker_1.idstring and Marker_2.idstring return the IDs of the marker entities Marker_1 and Marker_2 as strings. Therefore, when Inspire passes the expression to the solver, it becomes the following (assuming the marker IDs are 30102010 and 30102011, respectively):

`STEP( TIME, 1, 0, 1.5, 500*DX( 30102010 , 30102011 ) )`

Note: The IDs of markers and other solver entities are not defined before the model is passed to the solver or the operation Check Model is performed. Therefore, the marker IDs in the expression builder might appear blank when the parametric expressions are evaluated in the expression builder dialog.
Warning: The Evaluated check box only applies the Templex parser to the solver function (the parametric value and expression in the curly brackets). The correct format of the other information in the expression is solver-dependent and is not checked by Inspire. For example, if the step function is written stp, Inspire does not produce an error message when Evaluated is selected. However, the solver creates an error at run time.

Units

Parametric expressions have their own units, and any expression you enter assumes those units.

Expressions are evaluated in expression units but displayed in display units.

Solver expressions are passed to the solver as strings without unit conversion and are solved in solver units. However, if a solver expression includes parametric expressions, those parametric expressions are evaluated first in expression units before being combined with the remaining solver expression and sent to the solver.

You can change the expression units under File > Preferences > Inspire Motion > General > Analyst Expression Units.

Warning: Unexpected modeling or simulation behavior might occur if expressions are not written in the correct units as defined in the settings.
Tip: To avoid confusion, keep expression units, display units, and solver units the same.
Figure 4. Analyst Expression Units in Preferences


Example

Consider a non-linear spring-damper model that uses Expression units of MMKS, while the display units and solver units are in MKS.

Figure 5. Solver Units in Preferences


The other end of the spring damper End Point 2 is created 0.5 m in the Z direction from End Point 1. This is achieved by using a parametric expression p_end1.z+500. The value 500 is used instead of 0.5 because the Analyst Expression units chosen are MMKS, so the expression must be entered based on MMKS units.

Figure 6. End Point 2 Coordinates


The spring damper force, due to stiffness, is defined using a spline, for which the independent variable is a solver expression that measures the displacement of the spring from its modeled position. The expression is as follows:

`{CoilSpring.len/1000} - {CoilSpring.DM}`

Figure 7. Independent Variable Expression


In this case, CoilSpring.len is an analyst parametric expression referring to the installed length of the spring damper. Its evaluated value is in Expression units. This expression needs to be scaled to convert it to the solver units (MKS).

Expression Builder

The Expression Builder lets you enter expressions in text boxes efficiently, reducing the need for extensive typing or memorization.

This interactive tool enables quick access to model data, as well as solver and mathematical functions, allowing you to build custom expressions. These expressions can be applied across various entities, such as controlling hard point locations, defining variables, or creating custom inputs.
Figure 8. Expression Builder


Add an Expression

Follow this workflow to add an expression using the Expression Builder tool.

  1. On the field entity, click the Expression Builder Brackets Icon icon.
  2. Optional: Add a solver or mathematical function.
    1. In the Functions section in the upper-left, select a function.
      Figure 9. Expression Builder Functions


    2. In the upper-right section, fill in the required fields. For fields that reference attributes of an existing modeling entity, you can:
      • Type the entity name followed by the desire attribute, or
      • Click the Expression Entity Selector Magnifying Glass icon to open the Entity Selection dialog to browse and select the entity and attribute.
      Figure 10. Expression Builder Attributes


      Figure 11. Entity Selection Dialog


    3. Click Insert to add the selected function to the Expression section.
  3. In the Expressions section, type mathematical equations or expressions.
    Note: You can combine typed expressions with inserted functions. Functions are added at the cursor’s current position.
  4. Optional: Select Evaluate to preview the result.