You are on page 1of 27

Aug.

NX EXPRESSIONS

Create an expression
1.

Choose Tools

Expression.

The Expressions dialog box opens.


2.

In the Type box, choose the type of expression to create, either Number or String.

3.

In the Name box, type a name for the expression.

4.

If you chose Number for Type, you can:


o

Choose a Dimensionality for the expression.

Choose a Unit type for the expression.

5.

Type a value or formula string in the Formula box.

6.

To create the expression, press Enter or click Accept Edit

The expression is added to the Expressions list.

Edit an expression
1.
2.

Choose Tools

Expression to open the Expressions dialog box.

Click the expression to edit in the list box. The expression's name and formula appear in the
Name and Formula boxes.
If you know the name of the expression to edit, you can type it in the Name box and tab to the
Formula box. The current value/formula automatically displays, and the expression is ready to
edit.

3.

4.

Make your edit changes. You can do any of the following:


o

Rename the expression by editing the existing name or typing a new name in the Name
box.

Edit the expression formula by inserting or typing new values or formula strings in the
Formula box.

Right-click another expression in the Expressions list box and choose Insert Formula to
insert that expression's formula at the cursor position in the Formula box.

Right-click another expression in the Expressions list box and choose Insert Name to
insert that expression's name at the cursor position in the Formula box (you can also
double-click an expression name in the list box to do the same thing).

Change the dimensionality and units of user-defined number expressions.

Cancel the edit by clicking Reject Edit

To finalize the edit, click Accept Edit


The expression updates in the list box.

Unrestricted

or press Enter.

Aug. 3

NX EXPRESSIONS

Access data from an external spreadsheet


This example shows how to use a function to access data from an external spreadsheet. The value in
cell B3 in the following spreadsheet is assigned to an expression named thickness.
A

1 Maximum Length 75
2 Width

15.5

3 Thickness

2.5

1.

Choose Tools

Expression.

2.

In the Expressions dialog box, in the Name box, type thickness.

3.

Click Functions

4.

In the Insert Function dialog box, from the Or Choose a Category list, select spreadsheet.

5.

From the list of functions, select ug_cell_read.

6.

Click OK.

7.

In the Function Arguments dialog box, click Specify a spreadsheet

8.

Navigate to your spreadsheet and click OK.

9.

In the Specify a Cell box, type B3

10.

Click OK.

The Expressions dialog box is displayed and the function appears in the Formula box.
ug_cell_read( "D:\spreadsheets\size_data.xlsx", "B3" )
11.

Verify the value of the expression and click OK.


In this example, the value of the expression is 2.5.

Note If the spreadsheet is modified, you can update the expression by clicking Refresh Values from
External Spreadsheet

in the Expressions dialog box.

Undo an expression operation


on the Standard Toolbar to undo any of the following types of changes you may have
Click Undo
made while working in the Expression dialog box:
Update a model
Delete an expression
Create an expression
Any edit done on an existing expression
Undo reverses all of the changes made back to whichever of the following occurred last:

Unrestricted

Aug. 3

NX EXPRESSIONS
The first edit
A model update
All edits after a model update
Choosing OK (only for Tools

Expression)

For example, if you made five expression edits, updated the model, and then made three more edits,
clicking Undo

once would reverse the last three edits.

If you made five edits and then updated the model and the update failed, clicking Undo
would reverse the five previous edits.

once

You may continue to undo changes until the expression list is in its original state when you started
working on expressions.

Query an embedded distance measure expression


If you use the Expressions Measure Distance option to create a distance measure while specifying a
feature parameter (for example, using the Parameter Entry Option menu), the measure becomes
embedded within the expression for the feature parameter. You can query such a distance measure by
selecting it in the expression string and clicking the Measure button.
For example, in the expression:
P58 (Simple Hole(26) Depth) = distance62/2
distance62 is the embedded distance measure.
1.

Highlight distance62 in the Formula box.

2.

Click Measure

The Measure Distance dialog box opens in the edit mode, and the ruler displays the original
measure.

Enter comments in expressions


1.

Choose Tools

Expression.

2.

In the Expressions dialog box, enter comments in one of these ways:


o

Right-click an expression and choose Edit Comment, enter a comment in the Comment
dialog box, and click OK.

Double-click the Comment cell for a particular expression, enter a comment in the
Comment dialog box, and click OK.

In the Formula box, type double forward slashes (//) at the end of your formula, type
your comment, and press Enter.

Unrestricted

Aug. 3

NX EXPRESSIONS
Example length = 2*width //comment text

Your comment appears in the Comment cell for the selected expression.

Expressions
Expressions are arithmetic or conditional formulas that define some characteristics of features.
You can use expressions to control the relationships between the features of a part, or between parts
in an assembly. For example, you can express the thickness of a bracket in terms of its length. If the
length of the bracket is altered, the thickness automatically updates. You can use expressions to define
and control many dimensions of a model, such as the dimensions of a feature or a sketch.
The formulas within expressions can include a combination of variables, functions, numbers, operators,
and symbols. You can insert expression names in the formula strings of other expressions.
There are two kinds of expression naming conventions:
User expressions, those you create. These are also known as user defined expressions. User
expressions can have plain language names.
Software expressions, those NX creates. These expressions are named with a number preceded
with a lower case "p", such as "p53".
Following are some examples of expressions, their formulas, and their resulting values:
Expression
name

Additional software expression


name

Formula

Value

width

22

22

length

5*width

110

height

if (length<100) (45) else


(65)

65

p39

(Flange(6) Bend Allowance Formula)

p16

(Extract Region(7) Angle Toler)

(p26+(p64*0.44))*rad((-p24)) 18.849537

45.0

45

Where do I find it?


Menu

Tools Expression

Part
Navigator

In the Main panel or Details panel, right-click an expression and choose Edit in
Expression Editor

Dialog boxes In supported dialog boxes, click

Unrestricted

and choose Formula.

Aug. 3

NX EXPRESSIONS

User expressions
User expressions are any expression that you create yourself with the Expressions dialog box.
For example, you could create an expression named "width" with a formula string of "5.0". You could
then use this expression to define the dimensions of a block by entering "width" in the appropriate
parameter entry field.
You can create expressions based on measurements and interpart references.
Here is a sample of some user-defined expressions:
Expression Name

Formula

width

22

length

5*width

diameter

width/3

position

if (width<=2)(0.5*width) else (2)

base_block_height

16

base_block_length

base_block_multiple 8
base_block_width
block_heighta

base_block_height*block_multiple
(base_block_length/2)*a_multiple

block_length

a_multiple/2

block_multiple

base_block_width*block_multiple

BLOCK(6):Size X

block_length

div

3+sqrt(aln)

aln

5.4

railwidth
2*aln // forechain
By editing the formulas, you can edit your model parameters.
Note If you compare the results of your expressions you may in some cases see apparent inaccuracies
between known values. This may be due to normal system rounding and the nature of floating
point arithmetic when used with double precision values.

Unrestricted

Aug. 3

NX EXPRESSIONS

Software expressions
Most expressions are created automatically by NX as you build your model. When you create a feature
or a sketch, the parameters are defined by expressions. These expressions are named with a number
preceded with a lower case "p", such as "p53" though you can rename them. You can change the
parameters of a feature by editing and updating the expressions.
Software expressions are automatically created when you:
Create a feature
Dimension a sketch
Position a feature
Constrain an assembly
Additional parameter text may display for software expression names, but it is not part of the name.
This additional text follows the name and describes the feature and parameter option it is associated
with. In the example below, the software expression p5 is for the diameter of a simple hole feature
with a timestamp of 4:
p5 (SIMPLE_HOLE(4) Diameter)
Here are some examples of software expressions:
Expression

Formula

p28 (Extrude(14) Start Limit)

15

p3 (Edge Blend)(6) Radius 2)

21

p6 (Studio Surface 2X2(11) Angular Tolerance)

0.5

Unrestricted

Aug. 3

NX EXPRESSIONS

Expressions dialog box Details

Listed Expressions
Categories

Lets you choose a category to filter the expressions displayed in the list window.
Expression names are shown in the list window with no regard to case.
Select from the following categories:
User Defined
Shows expressions that you created.
Named
Shows expressions that you created and expressions that you renamed but
did not create.
Filter by Name
Used with the adjoining filter box to let you enter or select a string of
characters to show a subset of expressions by their names.
Filter by Value
Used with the adjoining filter box to let you enter or select a string of
characters to show a subset of expressions by their values.
Filter by Formula

Unrestricted

Aug. 3

NX EXPRESSIONS
Used with the adjoining filter box to let you enter or select a string of
characters to show a subset of expressions by their formula.
Filter by String
Used with the adjoining filter box to let you enter or select a string of
characters to show a subset of expressions by a particular string.
Filter by Comment
Used with the adjoining filter box to let you enter or select a string of
characters to show a subset of expressions by their comment text.
Filter by Expression Type
Used with the adjoining filter box to let you select from a list of expression
types to show a subset of expressions by their type.
Filter by Feature Type
Used with the adjoining filter box to let you select from a list of modeling
features of a selected type to show a subset of expressions.
Unused Expressions
Shows expressions that are not being used by any objects in the part file.
Object Parameters
Shows expression parameters for a feature selected in the graphics window
or Part Navigator.
Measurements
Shows all measurement expressions in the part file.
Attribute Expressions
Shows all part and object attribute expressions present in the part file.
All
Shows all expressions in the part file.
Filter box

Based on the filter category type (that is, Filter by Name, Filter by Formula, or
Filter by Feature Type) you can either enter a filter string or select from a list of
filters.
For categories that let you enter a filter string, you can use an asterisk wild-card to
filter the list further.

Spreadsheet Edit

Transfers control to the NX spreadsheet function, which you can use to edit
expressions. NX is idle until you exit the spreadsheet function.
Note

Legacy parts with Geometric expressions are not listed in the


spreadsheet.
The spreadsheet substitutes the string q... for each quote (), and a
question mark (?) for each colon (:) it encounters. You may therefore
wish to avoid using this option with interpart expression file names that
contain these characters. For example, an interpart expression with the
formula mypart::myexpression appears in the spreadsheet as
q...mypartq...??myexpression.

Unrestricted

Aug. 3

NX EXPRESSIONS
Reads a specified text file containing expressions into the current part file.

There may be times when you have expressions in the text file that have the same
Import
Expressions from name as expressions already in your part file. You control how expression name
conflicts are handled with one of the options shown below.
File
Replace Existing
Replaces the existing expressions that have the same name with expressions
contained in the text file.
Keep Existing
Imports only those expressions that do not conflict (do not exist in both
files.) Choose if you do not wish to replace the existing expressions with
expressions in the text file that have the same name.
When you use the Keep Existing setting, the system reads the specified text
file and attempts to add each expression to the list. If there are conflicts
(expressions with the same name) found during the transfer, an error
message appears. After the transfer is complete, you can choose Accept to
keep the new list or Undo to restore the original set of expressions.
Delete Imported
Lets you remove multiple expressions from your part file. When you choose
this option, the system looks at a text file that contains a list of expressions
and deletes any expression in the part file that has the same name.
This option may be used in one of the following two ways:
Export the list of expressions to a text file. In the text file delete all of
the expressions that you want to keep. Import the list using Delete
Imported.
Create an empty text file. Enter into the text file all of the names of
the expressions that you want to delete. (You do not have to type the
entire expression; just the name). Import the list using Delete
Imported.
With either of these methods, the expressions may be listed in any order.
Each expression that is encountered in the text file is deleted from the
Expressions List in the part file.
Note If the expression is used by the model or by another expression, it is
not deleted.
Note Legacy parts with Geometric expressions, such as p0=distance(40),
cannot be imported.
For additional information and format rules, see Expression Text File
Format.

Export
Expressions to
File

Unrestricted

Lets you write the expressions in the part to a text file. Choosing this option displays
a file dialog box prompting you for the name of the text file. You can choose what
expressions to export using the following options:
Work Part
Exports all the expressions in the work part.

Aug. 3

NX EXPRESSIONS
All in Assembly Tree
Exports all the expressions in the work part plus all of its components (the
assembly tree).
All Parts
Exports all the expressions in all parts in the session.
All files used for importing and exporting expressions have the .exp file
extension.
Note Legacy parts with geometric expressions in a file that is being
exported become "dumb" expressions (for example, an angle
expression, p0=angle(12) that evaluates to 90.0 becomes p0=90.0 in
the exported file).
For additional information and format rules, see Expression Text File
Format.

Expressions table
Displays a detailed, sortable list of the expressions in the part file. You can filter the expressions that
appear in the table using the Listed Expressions Category list and by entering filter-strings. You can
browse the graphics window and Part Navigator, selecting features to display their expressions in the
list.
Columns

The Expressions table is divided into the following columns:


Name - Shows the name of each expression or measure.
Formula - Shows the unevaluated right-hand side of the expression formula
for each expression. If the expression is a measure the label (Measure) displays.
Value - Shows the value derived by the formula or the measure data. If the
formula uses a different unit than the expression, the value is converted to the
expression unit. You can set the Type value to Number or String.
Units - Shows the units for the expression or measure, if they exist.
Type - Shows the expression type, as defined by the Type option.
Comment - Shows the comment for an expression if one has been added by
right-clicking and choosing Edit Comment, or by double-clicking the Comment
column.
Note Comments are not included when an expression is linked to another part
through an interpart expression.
Checks Shows any check requirements.

Icons

An icon may display with an expression or measure:


A Lock icon appears next to an expression that is locked.
A Read-only Icon appears if the expression is read-only.
A Measures icon appears if the expression is a measure.
The Knowledge Fusion adoption icon appears if the expression is controlled
from both the Expression editor and Knowledge Fusion.
For all expressions with icons except Lock and Knowledge Fusion, the expression text
is shown in light blue and the expression formula is not editable.

Unrestricted

Aug. 3

NX EXPRESSIONS

Create, edit, special functions, and controls


Type

Specifies the expression data type.


Number
Creates expressions using a numeric data type.
Dimensionality
When Number is the selected Type, the Dimensionality options list is
available.
Use these options to specify the kind of dimension to use for new
expressions. All types of dimensions specified by the Units Manager are
shown in the Dimensionality options list.
The most common types of dimensions used with Modeling expressions are:
Length
Distance
Angle
Constant (that is, dimensionless, as with the number of holes in an
instance array).
Both the dimensionality and the units you specify for an expression formula
must be correct with regard to the input and the expected output.
For example, if you create a new expression formula named C that multiplies
together two existing length expressions (A and B, created in millimeters) to
get an area (C=A*B), you would set the dimensionality of C to Area and the
units to mm^2. Otherwise, you may get a units inconsistency error.
You must also make sure that the function arguments in your expressions
have the correct dimensionality. The sqrt function, for example, fails with
the argument sqrt(x) when used with Length, because NX cannot calculate
the square root of a length dimensionality unit. But, if you write the function
as sqrt(x*in) for inches or sqrt(x*1mm) for millimeters, the function
succeeds. (Note that sqrt(x) succeeds when the dimensionality is Constant
instead of Length.)
You cannot change the dimensionality of a system generated expression.
String
Creates an expression using a string data type.
String expressions return a string instead of a number, and are defined as
double-quoted sequences of characters.
The formula for a string expression can be constant, such as text entry, or
it can be calculated.
For example, the following string expression:
NAME

FORMULA

mick

y2k+lg+yr+prep+terra

When used with these string expressions:

Unrestricted

Aug. 3

NX EXPRESSIONS
NAME

FORMULA

VALUE

lg
prep
terra
y2k
yr

Light
from
Home
2000
Years

Light
from
Home
2000
Years

Yields this value:


2000 Light Years from Home
The string expression formula can contain any combination of function calls,
operators, or constants that result in a string when the formula is evaluated.
You can use string expressions to direct a part's non-numeric values, such as
a part description, a vendor name, a color name, or other string attributes.
Boolean
Creates an expression to support alternate logical states using Boolean
values of true or false.
Use this data type to represent an opposing condition, such as the
suppression status for the Suppress by Expression and Component
Suppression commands.
Integer
Creates an expression using a numerical count without units.
Use this data type in commands that require a numerical count or quantity,
such as Instance Geometry.
Point
Creates an expression by defining a position using X, Y, and Z dimensions.
Formula syntax:
Point(0,0,0)
Use this data type in commands that require the specification or reference
of a position by expression. For example, you can parametrically control a
Revolve axis location, or the minimum distance location of an associative
Measure Distance.
Vector
Creates an expression by defining a direction using Cartesian I, J, and K
coordinates.
Formula syntax:
Vector(0,0,0)
Use this data type in commands that require either the input or the output
(measurement) of a direction. For example, you can parametrically control
an Extrude direction or a Revolve axis direction.
List
Use this data type to streamline NX DesignLogic interactions and provide
additional functionality capable of handling a wider variety of design tasks.
You can use the Extended Text Entry option to conveniently specify list

Unrestricted

Aug. 3

NX EXPRESSIONS
expressions with comma separated values of any DesignLogic data type as
list expressions using braces {}.
Name

Lets you specify a name for a new expression, change a name for an existing
expression, and highlight and display an existing expression for edit.
Expression names must begin with an alphabetic character, but can be composed of
alphanumeric characters. Expression names can include embedded underscores. You
cannot use any other special characters in an expression name.
Note

Expression names are not case sensitive, except under certain


conditions. See Expressions name case sensitivity for details.
Expressions names can be in the users supported international
language (locale). Both the left-hand side (LHS) and the right-hand side
(RHS) of an expression support internationalized name strings, as well as
DesignLogic functions and interpart expressions. Note that file names are
not internationalized in NX.

Unit

Available only when the Type is set to Number and the Dimensionality to something
other than Constant.
Specifies the unit for the selected dimensionality.
If you change the dimensionality type, the unit also changes.

Formula

Lets you edit the formula for an expression selected from the list, enter the formula
for a new expression, or create a reference for an interpart expression.
Use any of the following methods to fill in the Formula box:
Type an expression formula.
Select an expression from the list window to display its formula, and rightclick Insert Formula.
Click the Functions button to insert a function.
Click one of the Measurements buttons to specify an object measurement
from the graphics window and insert it into an expression.
Click the Create Interpart Reference button to insert an expression from
another part.
You can enter simple units in a formula, such as "3mm". Any necessary unit
conversions display in the Value column of the list window.
If you use different or inconsistent dimensions in the formula, a warning message
displays.
You can also enter statements in scientific notation. The value you enter must
contain a positive or negative sign. For example:
2e+5 for 200000
2e-5 for 0.00002
Note When you open the Expressions dialog box from a function's parameter entry
option, you can only edit the formula of the expression you are presently
creating. You cannot use the editor to change existing expressions, although
you can create new ones.

Unrestricted

Aug. 3

NX EXPRESSIONS
Tip Expressions created for Symbolic Threads that have the Manual Input option off
are restricted in the Expressions dialog box, and are unavailable for change.
You can still edit these expressions using Edit Feature Parameters,
bypassing the Manual Input option. This level of protection has been put in
place to maintain standard values taken from the thread lookup tables.
Opens a window where you can edit expression strings and add Insert Function and
Insert Conditional statements.
Extended Text
This is convenient when specifying list expressions with comma separated values of
Entry
any DesignLogic data type as list expressions using braces {}.
Creates a new expression or finalizes the results of an edit on an existing expression.
The expression and its value are updated in the list box.
Accept Edit
Cancels the edit or creation operation and clears the Name and Formula boxes.
Reject Edit
Reduces the size of the Expressions dialog box and simplifies it by removing the
expressions table and several other options.
Less Options
Shows the entire Expressions dialog box.
More Options
Opens the Insert Function dialog box, to let you find and insert functions into your
expressions at the cursor position in the Expressions Formula box.
Functions

Insert Function dialog box


Enter Keywords to Search for a Function
Lets you enter key words into an input box. When text is present, press Find
to display a list of matching functions.
You can enter a function name or a part of a function name. For example,
entering "tan" displays a list of functions that contain the string "tan".
Or Choose a Category
Lets you choose a function category from a list. For user-defined functions, a
set of functions in one DFA file is a category.
Function list box
Displays a list of functions from the category that satisfy the Find or
Category search. The list box shows the Function Name and Return type.
You select a function from the list.
Information about the Selected Function
Displays a brief description of the function selected in the Function Name
list, its input arguments, and its return value.
Help About Selected Function
Displays the online help for the selected function when available.
Related Functions

Unrestricted

Aug. 3

NX EXPRESSIONS
Provides a list of related functions from which you can choose for further
information.
Function Arguments dialog box
After you select a function from the Insert Function dialog box and click OK, the
Function Arguments dialog box appears to let you specify parameters for the
function.
Construct call for:
Displays the function's name followed by a list window that describes the
function.
Required
Lists each required input parameter by name, followed by an input box
where you enter a value. The value entered must match the required data
type for the function's input parameter.
Some of the standard data types are:
Number - is a double precision, floating point number. For example: 3.14.
Integer - is a positive whole number, or a negative whole number, or zero.
For example: 11.
Boolean - can be True or False. Set the toggle box for True, clear the box for
False.
String - Is a double-quoted sequence of characters. For example: "Test".
More/Less Options
Click More Options (green down arrow) to display the Resulting Function Call
window. Click Less Options to hide the Resulting Function Call window.
Resulting Function Call
Displays the function and dynamically updates to display the values you
enter as input. You may have to toggle the More/Less Options to update the
window.
Add Quotes to String Arguments
Automatically adds quote to string arguments.
Note You can separate the functions you add to the Formula text box using
standard mathematical operators.
Caution When you use string categories in your formula, the result of evaluating the
formula must be a number.
Obtains measurement values from objects in the graphics window for your expression
formulas.
Measurements

When you obtain a measure, an expression for it is created and inserted at the
cursor position of the expression formula you are editing.
Measure Distance - Uses the Analysis Distance function to measure the
minimum distance between any two NX objects such as points, curves, planes,
bodies, edges, and faces. The system calculates the three-dimensional distance and

Unrestricted

Aug. 3

NX EXPRESSIONS
the two-dimensional distance relative to the XC, YC plane. In addition, it returns the
closest point on each object and the delta distances in absolute and work coordinate
systems.
If you use this option to create a distance measure while specifying a feature
parameter (for example, using the Parameter Entry Option menu), the measure
becomes embedded within the expression for the feature parameter. See Query an
embedded distance measure expression for instructions on how to query an
embedded measure expression.
Measure Length - Uses the Analysis Arc Length function to measure the arc
length of a curve or line. You can use selection intent and section building to
measure the length of a set of curves between intersection points.
Measure Angle - Uses the Analysis Angle function to display angle
measurements between two curves, between two planar objects (planes, Datum
Planes or Planar Faces), or between a line and a planar object.
Measure Bodies - Uses the Analysis Measure Bodies function to obtain volume,
mass, radius of gyration, centroid, and surface area of solid bodies.
Measure Area - Uses the Analysis Measure Faces function to calculate area and
perimeter values of body faces. The system creates multiple expressions for area
and perimeter.
For information on simplified measure commands and other details on measuring and
entering data, see Simple Measure commands in the Measuring and entering values
help.

Reference
Expressions

Lets you create attribute expressions, which you can use to reference part or object
attributes. If the part or object attribute is later modified the expression is updated
automatically.
Use attribute expressions when you need to refer to a part or object attribute as a
dynamically updated expression.
If you select an existing attribute expression from the list, the Formula box is
unavailable.
Reference Part Attribute - Opens the Attributes dialog box showing the
models part attributes. You can select a part attribute and edit its input for the
right hand side of the expression (RHS).
Reference Object Attribute - Opens the Attributes dialog box. If an object was
already selected before clicking this option, object attributes appear in the list. If
no object was selected, the object attribute dialog box is empty, and you will need
to select an object to populate the list.
As with the part attributes, you can select an object attribute of the model and edit
its input for the right-hand side of the expression (RHS).
Note For more information on attributes and the Attributes dialog box, see the

Unrestricted

Aug. 3

NX EXPRESSIONS
topics in the Work with Objects section of the Fundamentals help.

Create Single
Interpart
Expression

Lets you create an interpart reference. When you choose this option, the Select Part
dialog box opens, which lists the parts available in your session. You can either
select a part from the Choose loaded part list or click Choose Part File to select a
part from disk. You can also select a part from the graphics screen.
Once you have selected a part, all of the expressions in that part are listed. Select
an expression from the list and click OK.
A reference to the expression is then inserted in the Formula box at the cursor
location using the following syntax:
<part>::<expression>
If the part to which you are referring contains different units from the work part,
the reference automatically inserts the units operator around it. For example, if a
metric part refers to an inch part, it adds "in(inch_part::length)" to the text box. You
can control this behavior using the option button on the Expressions List dialog
showing the list of expressions in the part you have selected.
You can also create an interpart expression by typing it into the text box (e.g.
"x=comp::len").
For more information, see Interpart References.
Lets you simultaneously link multiple expressions from a source part into the current
work part.

Create Multiple You can choose from several automated naming options:
Interpart
Add Prefix/Add Suffix Adds a prefix or suffix to the source expression
Expressions
name when the interpart expression is created.
Replace Lets you specify a name to find and replace with another name of
your choosing.
Replace with Index Lets you replace the source expression name with a
name of your choosing. As more interpart expressions are created an index is
added to the name.

Edit Multiple
Interpart
Expressions

Lets you control the external references from a part file to expressions in other
parts. This opens the Edit Multiple Interpart Expressions dialog box, which contains
a list of all of the parts containing expressions referenced from the work part.
Use the following options to edit interpart references:
Change Referenced Part
Lets you change all expressions which refer to the part that you have selected to
refer to a new part.
Delete Reference
Deletes the interpart references to a selected part.
Delete All References
Deletes all interpart references in the work part and replaces them with constant
numeric values.

Unrestricted

Aug. 3

NX EXPRESSIONS
Lets you open any partially loaded parts in your session.

When you first open an assembly, NX does not load the full part file for each
Open Referenced component part; to save memory, only the information needed to display the
Parts
component part is loaded. When you change your work part, the system ensures that
the full part file is loaded so you can make changes to the part file.
When a part is partially loaded, you cannot change its solid bodies. When using
interpart expressions, it is possible to change an expression that governs the solid
model in a component part without that component being fully loaded.
If you change an expression in a partially-loaded part, a warning message is
displayed informing you that in order to see the full effect of the changes, you must
use the Open Referenced Part option.
Choosing this option displays a list of partially loaded parts that you can fully load.
The contents of the list are controlled by the options at the top of the dialog box.
The All Modified option lists all partially loaded parts whose expressions have been
modified. The All Referenced option lists all partially loaded parts whose
expressions are referenced by the work part.
You can either select a single part from the list, or use the Load All Parts In List
option to load all of the parts in the list box.
You can also use the Assembly Navigator to ensure that parts are fully loaded. In
addition, you can set a preference under Load Options to force all component parts
to be fully loaded.
Requirements

Select from the following requirements options:


New Requirement Opens the Ad Hoc Requirement dialog box that lets you
create a user requirement. The user requirement is a conditional statement (for
example, > 50). A check placed under this requirement specifies an expression to
compare to that conditional statement (for example, p2 > 50).
Note Requirements are not included when an expression is linked to another part
through an Interpart Reference (an interpart expression).
Choose Existing Requirement Opens the SelectReqt dialog box that lets you
add a new check for an expression under an existing requirement.
Note For further details, see the Check Requirements Help User Requirement
overview.
Updates the values of expressions that you may have made in an external
spreadsheet.

Refresh Values This option works with the ug_excel_*** functions that can be used in the
from External Expressions dialog box. Because NX does not understand when you have changed any
Spreadsheet
information in the spreadsheet, you can use this button to refresh those
expressions that read or write data to the spreadsheet.
The functions specify which spreadsheet you will be using. You can have multiple
spreadsheets that are referenced in the Expressions dialog box.
Lets you remove a selected user-defined expression. You can delete multiple
expressions when you use Ctrl+click to select them.

Unrestricted

Aug. 3

NX EXPRESSIONS
Delete

You cannot delete an expression that is in use, such as by a feature, sketch, or


mating condition.
Note NX may automatically delete any expressions no longer in use. For example, if
NX automatically creates the expression "p17" for the width of a slot, deleting
that slot causes "p17" to be deleted as well. This only happens if "p17" is not
used by any other expression. NX only deletes expressions that it
automatically created.

Expressions export text file format


You can export your expressions to a text file using the Export Expressions to File option in the
Expressions dialog box. You can import the expressions in this file to another part using the Import
Expressions from File option.
The exported file is generated by the system and ends with a *.exp file extension. If you need to
examine or edit the file you can refer to the format rules shown below.

File format
The expression file is encoded in UTF-8 format, a variable length character encoding that supports
Unicode. The encoded file is backwards compatible with ASCII and can be edited with a text editor.
If you edit the file you should use a text editor that can preserve the UTF-8 encoding, such as
notepad.exe on Windows. If the UTF-8 encoding is lost, you will not be able to re-import the expression
file into NX.
Note Wordpad.exe does not support UTF-8 encoding and should not be used to edit the expression file.
Every expression in the text file appears as a single line with the name on the left and the formula on
the right, separated by an equal sign (=).
Any line in the text file beginning with a `!' character specifies the file into which the expressions are
to be imported. In the following example, the first two expressions are imported into part "a_part" and
the second two are imported into "b_part".
!a_part a=1 b=2 !b_part a=100 b=1.01

Importing multi-lined expressions


To import multi-lined expressions, a back slash continuation marker (\) is required to concatenate the
following line to the expression. The following rules apply when using the continuation marker:
The continuation marker must be the last character in the line. Comments and other
characters (including blanks!) are not allowed after the back slash.
There is no maximum number of continuation lines. However, the maximum number of
characters in an expression is 128. The continuation markers do not count as part of this limit
(they are removed when the expression is imported).
When the system imports the expression, it concatenates all the lines into a single line
expression.
Below is an example of an imported expression, both before and after the expression is imported:
Before import:
l = 5 w = 2*1 h = len*len + \ w*len + \ 2*w // comment

Unrestricted

Aug. 3

NX EXPRESSIONS

After import:
len = 5 w = 2*len h = len*len +w*len + 2*w //comment
Note Exported expressions are not formatted into multiple lines or into the multi-lined format.

Where do I find it?


Menu

Tools Expression
Import Expressions from File

Location in dialog box Export Expressions to File

Import a part file with expressions


When you import a part that contains expressions, the system places a tag at the end of each
expression name. The tags identify where the expressions come from and ensure that no two
expressions have the same name.
The tag is an apostrophe followed by a number. For example:
Name

Formula

longstrut'0

2*width

width'0

The first tag number, zero, is assigned to the expressions from the first file you import. The tag
number increases by one for each additional file you import.
Example Assume that you import a part that has three expressions - p1, p2, and p3. The expressions
p1'0, p2'0, and p3'0 are added to the expression list. If you import another part that contains
the expressions p0 and p1, the expressions p0'1 and p1'1 are added to the expression list.
If there is a units conflict when importing parts containing expressions, those expressions are not
converted to the other unit system. This also applies to expressions created by the system as
parameters on features.

Expressions shortcut menu


Shortcut options in the Expressions dialog box
Insert Name

Unrestricted

Inserts the name of the expression beneath the cursor in the Listed Expressions window
at the cursor position in the Formula field.

Aug. 3

Insert
Formula
Insert X
Formula
Insert Y
Formula
Insert Z
Formula

NX EXPRESSIONS
Inserts the formula of the expression beneath the cursor in the Listed Expressions
window at the cursor position in the Formula field.

Only available for point type expressions.


Inserts the formula of the selected point type expressions X, Y, or Z coordinate in the
Formula field.

Delete

Deletes the expression beneath the cursor in the Listed Expressions window. If the
expression is in use, this option is unavailable.

Edit
Comment

Opens a text window where you can enter commentary text for the expression beneath
the cursor in the Listed Expressions window. The text you enter displays in the
Comment column for that expression.

List
References

Lists a description in the Information window showing where a selected expression is


used. With interpart expressions, this option only lists usage by parts that are currently
loaded in the session.

Add a check

Create New Requirement Opens the Ad Hoc Requirement dialog box, which lets you
create a user requirement.
Choose Existing Requirement Opens the Check Requirements dialog box, which lets
you add a new check for an expression under an existing requirement.

Lock
Formula

Locks an expression formula value.

Unlock
Formula

Unlocks an expression formula value.

Unrestricted

Aug. 3

NX EXPRESSIONS

Conditional expressions
Expressions can be used to define a variable based on specific conditions. This kind of expression is
created by using the if-else statement.
Name

Formula

Lgth

12.5

Wdth

if ( Lgth > 10 ) ( 5 ) else ( 3 )

The expression for Wdth is defined depending on the following statement:


If Lgth is greater than 10, Wdth is equal to 5.
If Lgth is less than or equal to 10, Wdth is equal to 3.
Expressions can also use Boolean operations such as AND or OR.
Name

Formula

Lgth

12.5

Wdth

if ( Lgth > 0 && Lgth < 10 ) ( 3 ) else ( 5 )

Here, the expression for Wdth is defined depending on the following statement:
If Lgth is greater than 0 AND less than 10, the value for Wdth is 3.
Otherwise the value of Wdth is 5.
Syntax and the command portions of the statement must be in lowercase.

Expressions syntax operators


There are several types of operators that you may use in your expression formulas.

Arithmetic Operators
The following tables list the arithmetic operators.
Arithmetic Operators
+ Addition
- Subtraction and Negative Sign
* Multiplication
/ Division
% Modulus
^ Exponential
= Assignment
Note The modulus operator is the same as the C programming language operator, whose operands and

Unrestricted

Aug. 3

NX EXPRESSIONS
output are integers. Decimal places are ignored.

Relational, Equality and Logical Operators


The following table lists the relational, equality, and logical operators.
Relational, Equality and Logical Operators
>

Greater Than

<

Less Than

>=

Greater Than or Equal

<=

Less Than or Equal

==

Equal

!=

Not Equal

Negate

& or &&

Logical AND

| or ||

Logical OR

Expressions syntax precedence and associativity


The precedence and associativity of these operators are outlined in the next table. Operators in the
same row have equal precedence while operators in following rows have less precedence.
Precedence and Associativity
Operators
^

Associativity
Right to Left

- (Negative Sign) ! Right to Left


*/%

Left to Right

+-

Left to Right

> < >= <=

Left to Right

== !=

Left to Right

&&

Left to Right

||

Left to Right

Right to Left

When using operators with the same precedence in an equation without parentheses, use the left-toright or the right-to-left rule from the table. For example, in the expression X=90 - 10 + 30, X has a
value of 110, not 50.

Unrestricted

Aug. 3

NX EXPRESSIONS

Expressions built-in functions

Built-in functions include math, string, and engineering functions.

Scientific Notation
You may optionally enter numbers in scientific notation. The value you enter must contain a positive or
negative sign. For example, you can enter:
2e+5 which is the same as the value 200000
2e-5 which is the same as the value .00002
Below is a table of only some of the available built-in functions.
Built-in functions
abs

Returns the absolute value of a given number

arccos

Returns the inverse cosine of a given number in degrees

arcsin

Returns the inverse sine of a given number in degrees

arctan

Returns the inverse tangent of a given number in degrees from 90 to +90

arctan2

Returns the inverse tangent of a given delta x divided by a given delta y in degrees
from 180 to +180

ASCII

Returns the ASCII code of the first character in a given string or zero if the string is
empty

ceiling

Returns the smallest integer that is bigger than a given number

Char

Returns the ASCII character for a given integer in the range 1 to 255

charReplace

Returns a new string from a given source string, character to replace and the
corresponding replacement characters.

compareString

Case sensitive compare of two strings

cos

Returns the cosine of a given number in degrees

dateTimeString

Returns the system date and time in the format Fri Nov 21 09:56:12 2005/n

floor

Returns the largest integer less than or equal to a given number

format

Returns a formatted string, using C-style formatting specification

getenv

Returns the string value of a given environment variable string

hypcos

Returns the hyperbolic cosine of a given number

hypsin

Returns the hyperbolic sine of a given number

hyptan

Returns the hyperbolic tangent of a given number

log

Returns the natural logarithm of a given number

Unrestricted

Aug. 3

NX EXPRESSIONS
Built-in functions

log10

Returns the logarithm base 10 of a given number

MakeNumber

Returns the number or integer of a given numerical string

max

Returns the largest number from a given number and additional numbers

min

Returns the smallest number from a given number and additional numbers

mod

Returns the remainder (modulus) when a given numerator is divided by a given


denominator (by integer division)

NormalizeAngle

Normalizes a given angle (degrees) to be between 0 and 360 degrees

pi()

Returns pi

Radians

Converts an angle in degrees into radians

replaceString

Replaces all occurrences of str1 with str2

round

Returns the integer nearest to a given number, returns the even integer if the given
number ends in .5

sin

Returns the sine of a given number in degrees

sqrt

Returns the inverse square root of a given positive number

StringLower

Returns a lowercase string from a given string

StringUpper

Returns an uppercase string from a given string

StringValue

Returns a string containing a textual representation of a given value

subString

Returns a new string containing a subset of the elements from the original list

tan

Returns the sine of a given number

ug_ functions

see the documentation for descriptions of dozens more specialized math and
engineering functions

List expressions
You can list your expressions in the Expression dialog box by choosing All for the Listed Expressions
option.
You can list all expressions in the current assembly, including components, as well as expressions
loaded in the current session by choosing Information Expression.

Unrestricted

Aug. 3

NX EXPRESSIONS

Expressions name case sensitivity


In general, expression names are not case sensitive. This means, for example, that the software can
not distinguish between expressions named x1 and X1.
The following exceptions may occur:
Expression names may be case sensitive if their dimensionality is initially set to Constant.
Expression names may be case sensitive if they were created before NX 3.
When expression names are case sensitive they must be referenced exactly when used in other
expressions.

Linking references to expressions across parts (Interpart


references)
You can link references to expressions across parts so that expressions in one part are defined in terms
of expressions in another part. Expressions in an assembly can override expressions in a component.
Using interpart references (also known as interpart expressions) lets you model relationships between
components. A pin in one component designed to fit into a hole in another can have its parameters
associated to the hole's parameters, so that when the hole is edited, the pin automatically updates.
Use Expression options to create interpart references and edit or delete them.
Note The interpart reference capability is controlled by the Assemblies, Allow Interpart Modeling
customer default. If it is turned off, you will not be able to use interpart references.

Syntax
The syntax for an interpart reference is as follows:
part_name::expression
For example, the expression
Name

Formula

hole_dia pin::diameter+tolerance
relates the local expression "hole_dia" to the expression "diameter" in the part "pin".
Note No spaces are allowed before or after the "::" characters.

Quoting Filenames
If you are creating an interpart reference to a part with characters that the expression reader might
misread, you must enclose the part name in double quotes. For example, if you have a part named
"top-level" with expression "len", create the expression as:
"top-level"::len
Without the quotes this would be read as:

Unrestricted

Aug. 3

NX EXPRESSIONS
top-level::len - top - (level::len)

which would be incorrect.


Note Only file names must be quoted, and only if they contain characters which are special to the
expressions reader. These characters are as follows:
' ' (space) = + - * / ( ) : ^ ! < &

Overriding Expressions
An interpart expression that alters the expression in the referenced part is called an overriding
expression. Following is an example of an overriding expression:
Name

Formula

pin::diameter+tolerance 20
To get an overriding expression, you must cut and paste the name of an Interpart Reference from the
Formula field and paste it into the Name field. Then, enter the new, overriding formula into the
Formula field.
When you accept the edit, the system re-interprets the expression.
Overriding expressions are only allowed between assemblies and their components.

Updating Interpart Reference Expressions


When you edit an expression, all of the loaded parts that reference it are updated when the system
applies the edit. If you have partially loaded parts that reference the expression, a warning message is
displayed, and you are given the option of loading those parts fully.

Editing Interpart Reference Expressions


You can edit the references expression made from a part. You can change all references from a given
part to refer to the same expressions in another part.
For example, if you have:
x = part1::length
y = part1::width
part1::height = 10
you can change all references to "part1" to refer to "part2":
x = part2::length
y = part2::width
part2::height = 10
You can also delete all interpart links and replace them with constant values.

Unrestricted