Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Expressions NX9: "IF" statements

Status
Not open for further replies.

3dr

Automotive
Jul 10, 2004
451
I'm successfully using these to develop smart models that can be globally morphed. Typically commercial hardware that comes in a family of different sizes. But when I use conditional "if" statements I'm only able to look at a numeric expression. I would like to be able to look at more than just that. Is it possible to use an expression like "Y" "N" or an alphanumeric like "LJ.750" ???

I'm sure this is basic stuff for many of you... can you help the newb???

TIA

Dave
 
Replies continue below

Recommended for you

Yes, by using String expressions, you can utilize any non-numerical 'value'. Also, for something like 'Yes' and 'No' situations (I assume that that is what you're trying to do with your "Y" and "N" examples) you can use Booleans instead. For example, in the part file attached below, I've created a couple of different expressions using IF statements to control the diameter and length of the cylindrical body. For the length of the cylinder, I've created a String expression 'Condition_2' equal to "Y" which will set the value to 25. Any other value of 'Condition_2' will set the value to 50. For the diameter I'm using a Boolean expression, 'Condition_1', that is being driven from a Boolean Part Attribute named 'Condition'. Now all that you have to do is go to...

File -> Properties -> Attributes

...and change the value of the Attribute 'Condition' from 'True' to 'False'. Note that since this is a Boolean attribute it can have only one of two values, 'True' or 'False' (this can provide you with your YES/NO logic).

Anyway, tale a look and see if this will help you with what you're attempting to do.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
 http://files.engineering.com/getfile.aspx?folder=49188791-fae5-4fd5-849b-37f74f18f81b&file=expression_examples.prt
Wow, this is good stuff John. Thank you! I can do an awful lot with what you've shown me in this example file.

I'm working my way up to feature suppression by expression as well. I know I've seen posts referencing that in the past.

Is that something you can enlighten me on as well?? I've never done it but I can see where it will be very useful.

TIA again.

Dave

 
After creating your model with all the features, in NX 9.0 go to...

Menu -> Edit -> Feature -> Suppress by Expression...

...and select the feature(s) that you wish to control and hit OK. Now go to the Expression dialog and you'll find a new expression which references the feature selected and indicating its 'Suppression Status', which when the value is '1' it is NOT suppressed, but when the value is '0' it is. Now by using the IF logic examples thst you've already seen, you can control exactly under what conditions will the feature(s) be suppressed or not. Note that if you select more than one feature to suppress, the 'Suppress by Expression' dialog will offer you an option to either create a unique suppression expression for each feature selected or a single expression that will control all of them.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Also, when looking at the Part Navigator, Features which have a Suppression Expression assigned to them will have had their status symbol, the little square with the Green 'checkmark', modified showing it dashed instead of solid. And when a feature is actually suppressed using the expression, instead of the box being blank it will have a blue 'equal sign' in it. Also, if you enable to 'Status' column in the Part Navigator, it will indicate that the feature was suppressed by an expression. Also note that once you've set-up a feature to be Suppressed by Expression you are NOT able to manually suppress it. If you try to do so, you'll get a message in the status line indicating that this feature is controlled by an expression.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Got it... thank you again. This is great stuff. Now to cram in a week of nothing but this and I'll be an expert.

I really like this method of controlling families of standard parts. That is with out using part families. There is no spread sheet connection or master part to break off from when doing this. The simple change of a catalog number in an expression or attribute morphs the whole part or entire assembly into something else. Including links to construction solids used in mating parts. There are no other dependencies to manage.

However, two weaknesses in how this presents to the user are:

1. There are a lot of expressions used to control a feature rich part. All of which are in the "user" expression category. Is there a way to hide them in a different category to simplify what the user is presented with???? It would be much nicer to only see the expressions that require user input.

2. If the model / ass'y is driven with a variable such as a part number... there may be dozens of long catalog numbers that are very similar. LJ.750.013, LJ.750.025, LJ.500.100 ETC... Any suggestions on where they can be stored within the part file for reference? Or even to cut and paste? A PMI note... a simple drafting table?? I normally use the comment section when the options are small. But the lengthy stuff doesn't make that practical.

Just getting this far has taken some time. While I know there are more advanced ways of making and presenting dialogue boxes. I doubt that is within reach for me at this point.

TIA once again and cheers!

Dave
 
For both #1 and #2 I'd look at using Attributes to drive Expressiona. For #1 you could put all of your 'user entry' 'expressions' as Attributes, entering them from there. And using Attributes also allows you to control such things a floating point values versus integer entry. Or if there are a limited number of valid inputs, you could create a list of only those values which are valid, and of course you can use the Boolean attributes for simple True/False (i.e YES/NO) choices.

As for #2, again you could use a String Attributes with pre-defined set of valid entries.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Ok... do you mean you can place the math into an attribute or just use the attributes to isolate the expressions to the standard naming schemes of p312, p313 etc... to keep them out of the "user" expressions list??

I'm thinking the latter of the two... I can try it this after noon.

Dave
 
No, the use of the attributes will not necessarily change the listing behavior when in the expression system, just that using the Attribute dialog as the 'portal' for accessing those 'expressions' which you would like the user to modify allows you to hide everything except that which you've deemed as relevant. It's like in that original model I shared with you. You could have told someone to open the expression dialog and edit the "Y" value to "N", or you could have told them to go to the Attribute dialog and simply switch the Boolean attribute from "True" to "False". That way they need to know nothing about the Expressions themselves. You could have a hundred expressions with different names and created using different techniques yet all of that could remain hidden by simply using a few Attributes to change the driving parameters of your design. And since you can set up lists of possible values, control floating point versus integer, binary (True/False) conditions or just a simple user entered value, you'll have a lot more flexibility to create an 'interface' suited to the skills of the user as well as hiding all the gory details.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Yes, Thanks John. I can see exactly what you mean now and that's pretty slick. I may or may not use the attribute portal method because I can't gain access to those attributes with out making the component the "displayed" part. Unless of course you can take me to school on that too!? I'd like to be wrong but that is the only way I know to get at them at this point.

Alternatively, if I make the part the "work" part from a higher assembly level, the "user" expressions are available in the part navigator. Being able to reach down from multiple levels up to make the changes is an important benefit. It allows the user to visually witness it in real time. I've found that very handy in immediately identifying positive and negative effects of the change. Sometimes there is a bad "mate" or "wave link" that stands out when the shift takes place.

Dave
 
3dr said:
I can't gain access to those attributes with out making the component the "displayed" part

Select your component, choose properties -> Attributes; change the 'context' setting from component to part. You now have access to the part's attributes.

www.nxjournaling.com
 
Your kidding me.. I've suffered with that forever!

Thanks Cowski. Is there a way to make that the default setting????

Dave
 
Don't feel too bad... It was added fairly recently (NX8?). If you recently upgraded from NX7.5, it was never an option for you.

I don't know how to make it the default, perhaps dialog memory will open it to the last used option?

www.nxjournaling.com
 
Yes, it is the same/similar thing. It was re-labeled in 8.5 and 9 and might have an added option. I'll have to look again when I'm back in front of NX.

www.nxjournaling.com
 
The functionality was added in NX 8.0 as part of the larger Attribute enhancement project. The only thing that we did in NX 8.5 was to clean-up the terminology used since it was confusing and was a bit too wordy, as seen below.

This is what the NX 8.0 Component Properties dialog looks like:

NX80Componentpropertiesdialog_zpsb783957b.png


And this is what the NX 8.5 Component Properties dialog looks like:

NX85Componentpropertiesdialog_zps68cc7a18.png


John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Hello John,

You stated "And since you can set up lists of possible values".
Is this a list off possible Attribute Values?
And if so, how is this done?

Kind regards,


 
Ok... I'm sold on the "attribute" driven method since I can gain direct access to them from higher up in the assembly. I've got my first part family ready to go.

My only gripe is that I just noticed all four "context" selections on the attributes tab look exactly alike. The dialogue opens in the "Component" context. Which displays exactly the same attributes as the "Part" Context. You can even change the attributes in Component context but of course nothing happens.

It's just easily confusing even for me the guy who set it up... let alone another user.

Do you have any recommendations for this?? Other than deal with it! lol

TIA Dave
 
Good Question PascalDW. I didn't notice that comment.

If this can be done it could be a huge asset. I noticed there is a "Allow multiple Values" Check box in the Attribute Dialogue. I'm wondering if this provides a window to list of some sort. I tried the help files "in context" to find out and didn't notice anything info on it.

Dave
 
Part Attributes are inherited as Object Attributes of the Component when it's added to an Assembly. What you're seeing initially are these inherited Attributes. But changing or adding new ones, excpet for that last option which gives you access to the actual Part Attributes of the master part model, in the 'context' of the Assembly will effect THAT particular Component in THAT paricuar Assembly. As for the 'Instance' option that is for cases where the same Component might have been added multiple times to the same Assembly, such as a pair of brackets and you'd like to edit/edd a different attribute to ONE of the 'Instances' but not the other. If you edit/add the attribute to the 'Component' itself then it will apply to ALL instances in the Assembly. I hope the clears things up for you.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor