Expressions and Functions for Forces and Motors

You can use mathematical expressions to define forces or motor action in a Motion Analysis study.

To create an expression:

Select Expression in the Force or Motor PropertyManager.

You can use only supported functions when you compose mathematical expressions for motors or forces.

Expression Function Basics

An expression function is a C-like or FORTRAN-like expression that returns a single value. You can use any valid combination of simple constants, operators, results (for example velocity, acceleration, power, or force plots), and available supported functions to compose expressions.

Constants

You can include only integers and real numbers in expressions. Complex numbers are not supported.

Operators

SOLIDWORKS Motion includes arithmetic operators with precedence as follows.
Symbol Operation Precedence
** Exponentiation 1
/ Division 2
* Multiplication 3
+/- Addition/Subtraction 4
You can include any number of blank spaces in an expression function. You can include blank spaces to improve the readability of the function expression. The following are restrictions on using blanks:
  • You cannot put a blank space in the middle of a number.
  • You cannot put a blank space between a function and its left bracket.

SOLIDWORKS Motion Results

Many of the functions supported can also use SOLIDWORKS Motion results as variables.

If you are using a function that allows the use of a SOLIDWORKS Motion result as an argument, double-click a result from the list to enter it in the expression.

You must create a result before you can use it in an expression.

Limitations

There are some limitations in the definition of functions:

Nesting of functions

You can nest functions, sub-expressions, or operations for up to ten levels. For example, FUNCTION = f1(f2(f3(f4))), where f1, f2, f3, f4 are function sub-expressions, is a syntactically legal function definition. However, FUNCTION = f1 (f2(... (f11 ) ...) is not a legal definition, since sub-expressions have been nested eleven levels deep.

Limitations on number of symbols in a function expression

Do not use more than 1,000 symbols in an expression. This includes operators, brackets, functions, and numbers.

Limitations on number of elements to which a function can refer

Do not define a function that depends on more than 25 standard elements of each type. All expressions you create must depend on at most 25 parts, 25 forces, and so on.