Nx Expressions

April 11, 2017 | Author: prasenjitsayantan | Category: N/A
Share Embed Donate


Short Description

Download Nx Expressions...

Description

Aug. 3

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.

o

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.

o

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

o

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.

o

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).

o

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

o

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

B

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.

o

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

o

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 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

5

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 expression’s 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

< >=
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF