Equations, Expressions and Variables Updated for the current release.

 

Variable, equations and expressions can be used to parametrically drive parts, sketches and drawing sheets. Variables can be created and assigned absolute values or values implicitly derived from dimensions. Expressions can be created and used as input during command prompts. Expressions can contain variables as well as conditional (if/then/else) operators.

 

Equations can be created that contain variables as well as one or more expressions (i.e., equation sets). You can set equations to be solved sequentially (linear) or simultaneously (nonlinear). You can also test the results of an equation set on the active part.

 

There is no icon for this command Insert Part Equations

 

Invoked ByInsert go to Equation Set (Part Level)

 

Use this command at the Part Level to create a part equation (or equation set) using the Equation Set Editor. A part equation set is one that resides in the active part. The active part can have any number of equation sets. Each equation set can consist of one or more equations. You can also create a new equation set in a new VX file at the same time using the New File/Object Form.  See also Using Command Line Expressions.

 

 

There is no icon for this command Edit Part Equations

 

Invoked ByTools go toHistory Managergo toRight-click on Object to Edit(on Equation Set) go to Edit

 

New equation sets are assigned system generated names (i.e., EquationSet1, EquationSet2, EquationSet3, etc...). You can rename or edit the equation set by right-clicking on its name in the History Manager and selecting Edit or Rename. You can use the History Manager filter to list only the equation sets.

 

 

Insert Sketch Equations Insert Sketch Equations

 

Invoked ByEdit go to Equations... (Sketch Level)
 

Use this command at the Sketch Level to create or load a sketch equation (or equation set) into the Equation Set Editor. A sketch equation is one that resides in and is always associated with the sketch that is active at the time it is created. Thus, there is only one equation set per sketch and it is created and editing in the same way.
 

 

The Equation Set Editor

 

Invoked ByInsert go to Equation Set (Part Level)

 

Use this editor to build an equation or equation set (non-linear and simultaneous). As you build each equation, it is appended to the scrolling list of equations. An equation set is constructed of any number of individual expressions. You can test the results of the equation set on the active part by picking Apply.

 

Equation Set Editor

 

 

Information about VXOperational Sequence

 

  1. Enter a variable name in the input field provided.

  2. Build an expression in the input field provided. You can use the Get Dimension or Get Variable buttons as described below to add dimensions or variables to the expression.

  3. After the expression is defined, press the Submit button. The values currently expressed in the Name, Expression, Min, and Max input fields are appended to the end of the scrolling list of equations or replaces any existing equation with the same variable name.

 
The format used to display the definition of an equation in the list is:

 

name = value {expression} [min, max]

 

If an expression hasn't been evaluated yet, its result is shown as an underscored blank space. The Apply button logs changes to the Equation Set to the database and updates the values.

 

  1. Repeat steps 1, 2, and 3 as desired to build an equation set.  

  2. Pick OK to save the equation set or pick Apply, Reset, or Cancel as desired (see Other Options below).
     

 

Equation Input

 

Name

Enter the variable name for the equation or pick Get Dimension and select a dimension or pick Get Variable and select a variable from the Variable Browser.
 

The name of the dimension or variable will appear in the input field and will be used as the variable name.

 

Min/Max

Enter the Minimum/Maximum value for the variable. An error message is displayed if a variable exceeds its limits. No change to its value is made.

 

Distance

Check this box if the variable as a distance. When a variable is flagged as a distance, the variable's value is converted to the active units when it is displayed. The expressions that define a variable are still interpreted as millimeters and degrees unless alternate units are explicitly declared (e.g., 5.in).

 

Expression

Build the expression for the equation in the text input field provided (e.g., eq1-10 or (v1+2)/v2). You can use existing dimensions and variables within the expression. Pick Get Dimension and select a dimension or pick Get Variable and select a variable from the Variable Browser.  See also Using If, Then, Else Operators in Expressions

 

Get Dimension

Select a dimension from the active part or press and hold the F7 key to select a dimension external to the active part.

 

The dimension name will be appended to either the Variable Name or Expression input field depending on which one is currently active. The name of the root object that the dimension belongs to is automatically appended to the dimension name. Refer to Variable Naming Conventions for more information.

 

Get Variable

Select a variable from the Variable Browser.  The variable name will be appended to either the Name or Expression input field depending on which one is currently active. If the variable belongs to a root object other than the active root object, the name of the root object that the variable belongs to is automatically appended to the variable name. Refer to Variable Naming Conventions for more information.

 

Display Dimension Value

Temporarily change the display format of all dimensions. The display format returns to Value when the Equation Set Editor is dismissed. Select from the following

 

 

 

Equation Options

 

Edit

The values for the selected equation will be displayed in the input fields. Edit the equation values and pick Submit update the equation in the set.

 

Delete

Deletes the selected equations in the list.

 

Move Up, Move Down

These move the actively selected equations up or down in the equation list. This is useful for re-ordering equations that are solved sequentially.

 

Unpick All

Unselect all equations that are currently selected.

 

Import

0441.gifUse this option to import variables or equations from a file. This supports the "family-of-parts" concept by allowing equation sets to be externally driven by a tabulated list of variables and their values or by equations. See Importing and Exporting Equations below for a more complete discussion of this topic.

 

Export

0441.gifEnter a path and file name to export the equation set to or pick the folder icon to use the File Browser. Picking the Export button will then export the equation set to the file in ASCII format. See Importing and Exporting Equations below for a more complete discussion of this topic.

 

Solve Method

Sets the method for solving the equation set. Select from the following:

 

 

Submit

Submits modifications in the equation edit area to the main equation list at the top of the Equation Set Editor. If the equation doesn't already exist in the list, it is added Before or After the actively-highlighted equation based on the setting of the Before/After toggle (see below).

 

Before, After

Insert an equation before or after the selected equation. Build the new equation in the input fields. Pick Submit to insert the equation.

 

 

Other Options

 

 

 

Information about VXImporting and Exporting Equations

 

The Import and Export buttons on the Equation Set Editorallow you to import or export variable values or equations to or from an ASCII file. If the variable already exists, you can choose to have its value updated from the file. If it does not exist, it is added to the Equation Set. The file formats for variable values and equations are different. Each is illustrated below followed by the operational sequence.

 

Information about VXASCII File Format for Variable Values

 

Format for Import Variables/Values from an ASCII File
 

Comments may be included in the file. They are lines preceded by a pound (#) sign. The first non-commented (#) row should be a list of comma-delimited or (tab-delimited) variable names preceded by a configuration label.

 

Subsequent rows should consist of a configuration name followed by a comma-delimited list of variable values that correspond to the variable names in the first row. If the character @ is appended to the end of a variable name (e.g., Config0001@), It will be flagged as a distance variable.

 

Information about VXASCII File Format for Equations

 

3786.gif

 

If the first non-blank, non-comment (#) line in the file contains the keyword "equations" (upper, lower or mixed case), it is assumed that subsequent lines contain equations formatted just as they appear in the in the

Equation Set Editor, as shown below :

 

Variable_Name=result {expression} [min,max]

 

"result" should be followed by a units abbreviation (e.g. mm) if the variable is a distance. If the value of "result" is not known, enter it as zero. Once the equations are loaded, the Solve button can be used to calculate the variable values (i.e. results).

 

The equation format should be followed exactly, including the inclusion or exclusion of blank spaces. The only exception is the format of "expression", which is not sensitive to the inclusion of extraneous blank spaces.

 

Enter min,max as [0,0] if there are no known or intended minimum and maximum bounds for "result".

 

 

Information about VXOperational Sequence (Importing Equations)

 

  1. Pick the Import button from the Equation Set Editor.
     

  2. File BrowserEnter the path and file name of the file to import or export in the text field provided or pick the folder icon to select a file using the File Browser.
     

  3. Pick the Import button and select a file using the File Browser. If the file contain variable values (see example above), it is opened and loaded into the Import Variable Data Form shown below (go to step 3). If the file contains equations (see example above), it is imported directly into the equation list and you are given the opportunity to overwrite any values if the equations currently exist in the list.
     

  4. Select a row of data from the form and pick OK. The highlighted row of data is parsed and used to update the active Equation Set.
     

 

Tips & TechniquesThe new variables/values imported into the Equation Set are not applied to the database until the OK or Apply buttons are pressed. Before the new data is applied to the database, the original data can be recovered with the Reset button. Once the data is applied to the database, the previous set of equations may be recovered using the Undo command.

 

 

Import Variable Data Form
Import Variable Data Form

 

Variables Imported into the Equation Set Editor
Variables Imported into the

Equation Set Editor (only partially shown)

 

 

Information about VXOperational Sequence (Exporting Equations)

 

  • Pick the Export button and enter a file name to export to using File Browser. The file extension is optional (e.g., equation.txt). The file will be exported to the file in ASCII format (refer to the example above).

 

 

Information about VX Variable Naming Conventions

 

Variable names should start with an alphabetic character and all other characters must be alphanumeric or "_". Variable names can begin with numeric characters if the entire variable name is enclosed in brackets.  If you submit an invalid name, like "Var One", you will get the following error message: "Character 4 of name [Var One] is invalid."

 

Existing equation sets (prior to VX 6.5) which currently contain invalid variable names will regenerate. However if you edit an equation set with an invalid variable name, VX will now require you to fix any invalid variable names before the edited equation set can be saved.

 

Variable Naming Conventions

variable name
 

Example: height

All sub-objects of the active root object are searched for the variable named "height".

root name:variable name
 

Example:

bracket:height

or

equation_set_name:height

All sub-objects of the root object named "bracket" are searched for the variable named "height". The root object must reside in a active session or a file located in one of the directories listed in the VX Search Path Form. If you want to reference a variable from a root equation set, you would do it using "equation set name:variable name".

~function name:string
 

Example: ~ObjectVolume:Part2

If a variable name begins with a tilde, it is assumed to be the name of a C language function of type "double function(char *)". For example, the variable named "~VxPathParam" retrieves the "path parameter" associated with the active target object.
 

The string following the colon (i.e., Part2) is passed to the function. The return value of ObjectVolume() is output by this function as "value".If there is not a string following the function name, a NULL pointer is passed to the function.

variable name

[22base_3]

Variable names can begin with numeric characters if the entire variable name is enclosed in brackets.

@file_name,variable_name

When a variable with this syntax is included in an expression, it is evaluated by searching "vxpaths" for the file named "file_name."  This file is then searched for a string with the syntax {variable_name=value}.  If it is found, "value" is parsed from the string and is used as the value of the variable.

file_name:part_name:variable_name

A variable in another part can be referenced as "part_name:variable_name."  VX searches "vxpaths" for the first file that contains "part_name."  To speed up the search, and to account for multiple files with the same part name, you can optionally specify a file name along with the part name and variable name.  

See also Referencing Variables from Parts Associated with Drawing Sheets below (this page) for exceptions.

 

 

Information about VX Variable Names and Sketch Dimensions

 

Variable names can have the same name as an existing dimension in a sketch. This is one way to drive dimensions in sketches. At the path level, checking is still done to prevent a variable introduced by an equation set from having the same name as another variable or dimension in the part. In a part, to drive a dimension by a variable, you have to use the variable as input for the feature parameter associated with the dimension.

 

 

Information about VX Using Command Line Expressions

 

When prompted for a value during many VX commands, you can right-click to display an input options menu that contains the option called Expression. Selecting this option will display the Input Expression Form shown below. An input field is provided for entering an expression that contains valid expression functions. You can also get dimensions and variables to use in your expressions. Each option is described below. When you pick OK, the expression is evaluated and entered as input for the active command prompt.

 

 

Expression Input Form

 

 

Input Expression Form

 

Expression input field

Enter the desired expression here. Refer to Valid Expression Functions and Using If, Then, Else Operators in Expressions for guidance.

 

Get Dimension

Select a dimension from the active part or press and hold the F7 key to select a dimension external to the active part.

 

The dimension name will be appended to the expression input field. The name of the root object that the dimension belongs to is automatically appended to the dimension name. Refer to Variable Naming Conventions for more information.

 

Get Variable

Select a variable from the Variable Browser.  The variable name will be appended to the expression input field. If the variable belongs to a root object other than the active root object, the name of the root object that the variable belongs to is automatically appended to the variable name. Refer to Variable Naming Conventions for more information.

 

 

Information about VX Valid Expression Functions

 

The following are considered valid functions for use in expressions (where X and Y are valid VX expressions).

 

Valid Expression Functions

sin(X), cos(X), tan(X)

Standard trig functions

sec(X), csc(X) and cot(X)

Standard trig functions where:

 

sec(X) = 1.0 / cos(X)

csc(X) = 1.0 / sin(X)

cot(X) = 1.0 / tan(X)

sinh(X), cosh(X), and tanh(X)

Hyperbolic trig functions where:

 

sinh(X) == ( exp(X) - exp(-X) ) / 2.0

cosh(X) == ( exp(X) + exp(-X) ) / 2.0

tanh(X) == sinh(X)/cosh(X)

asin(X), acos(X), atan(X)

Inverse of standard trig functions

atan2(Y, X)

Angle whose tangent is Y/X

abs(X)

Absolute value

log(X), ln(X)

logarithms (base 10, base e)

sqrt(X)

Square root

exp(X)

e to the power X

floor(X)

Greatest integer not greater than X

mod(X)

A function that returns the decimal portion of X, hence it is a double in the interval [0, 1). For positive values of X you may think of   mod(X) = X - floor(X)

atan2(Y,X)

Returns the angle (in radians) whose tangent is y/x.

 

 

Information about VX Using If, Then, Else Operators in Expressions

 

If_then_else type operators can be used in the expression evaluator. The syntax is similar to the conditional operator in the C programming language (E1 ? E2 : E3), you will enter "E1 then E2 else E3", which evaluates to E2 if E1 is "True" and E3 if E1 is "False". Expressions of the form "E1 then E2" are also supported. This expression is equivalent to the expression "E1 then E2 else 0", that is, if E1 is true it returns the value E2, if E1 is false it returns a value of zero.

 

The logical and relational operators shown below are also available to help form "True" and "False" expressions for E1 above.

 

Logical and Relational Operators used in Expressions

Operator

Description

<

less than

>

greater than

=

equal to

&

and

|

or

!

not

All the other typical relations can be formed from these (i.e., A != B is same as !( A = B ), A <= B is same as !(A > B ), ... ).

 

 

The hierarchy of operations assumed is also similar to standard C:
 

parenthesis

logical "not" (!)

unary + and -

exponents

unit conversion factors

MULTAX or divide

add or subtract

ordering relations (<, >, =)

logical "and", "or"

conditional expressions ( E1 then E2 else E3 )

variables and function evaluation
 

As usual, parenthesis should be used to avoid confusion.
 

Note:
 

"V = (5>11) then 55 else 111" would assign a value of 111 to V,

"V = 5>11 then 55 else 111" would assign a value of 0 to V,

because in this case the expression is treated like:

"5 > (11 then 55 else 111)" == "5 > 55" == "0".
 

 

Information about VX Using Units within Expressions

 

The specification of unit or unit expressions must begin with a '.' (4.2 .in). These may be concatenated (44.ft.lb) or inverted (100.kg/1.sec). VX interprets the notation "expression.units" as the value of "expression" currently expressed in "units" and converts to its equivalent value in system database units.
 

In the hierarchy of operations conversion is higher than multiplication, but lower than exponentiation. Thus 55.5.in*0.34.km is processed as (55.5.in) * (0.34.km) and 25^2.m is processed as (25^2).m. Parentheses have the highest priority and may always be used to avoid confusion.
 

If the expression only contains a numeric constant and it is known that the expression defines a distance, it is assumed that the constant defines a distance in the active units. Otherwise, no assumptions are made about the units of a number unless the units are explicitly declared as described above.

 

 

Information about VX Using Embedded Text Variables

 

You can embed variables inside text strings in parts, sketches and drawing sheets. The format is as follows:

 

Inside a text string: "You can embed this [$varname] inside of this text string."

 

Where varname is the name of the variable.

 

VX predefines part attribute data as text variables so that you can use them in this way.  For example, you can embed part attribute text variables within your title block so that the information gets updated automatically as the part attributes change.  Here is a list of text variables that are currently defined for part attributes.

 

part_number

part_class

part_designer

part_cost

part_supplier

part_description

part_keyword

part_manager

part_material

part_startdate

part_enddate

part_derived

part_<dimension label>

part_<user data label>

 

 

Information about VX Editing Command Line Expressions

 

Since command line expressions are considered driving parameters within features, you must edit the feature to edit the expression. You can use the History Editor to locate the feature and then right-click to edit it. You can also use the Redefine Feature command. See History Editing for more commands that work on a Part's History.

 

 

Information about VX Referencing Variables from Parts Associated with Drawing Sheets New in VX

 

You can reference variables from a part associated with the a drawing sheet without prefixing the variable name with the part name as stated in Variable naming Conventions above (this page).   You can just use the variable name.   Then, if the part referenced by the drawing sheet is changed, the sheet variable will automatically pull its value from the new part instead of the old.   

 

This is convenient for setting up a title block to pull information from whatever part is associated with a drawing sheet.  If you use the Replace Layout View Part command to change a part associated with a drawing sheet, you have to execute Regenerate Text (2D) command afterwards to update text strings that contain text variables.

 

 

 

VX Notes General Notes for Equations and Expressions

 

Return to VX CAD/CAM Index