Expressions NX9: "IF" statements
Expressions NX9: "IF" statements
(OP)
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
I'm sure this is basic stuff for many of you... can you help the newb???
TIA
Dave





RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
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
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
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
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
I'm thinking the latter of the two... I can try it this after noon.
Dave
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
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
RE: Expressions NX9: "IF" statements
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
RE: Expressions NX9: "IF" statements
Thanks Cowski. Is there a way to make that the default setting????
Dave
RE: Expressions NX9: "IF" statements
I don't know how to make it the default, perhaps dialog memory will open it to the last used option?
www.nxjournaling.com
RE: Expressions NX9: "IF" statements
RE: Expressions NX9: "IF" statements
www.nxjournaling.com
RE: Expressions NX9: "IF" statements
This is what the NX 8.0 Component Properties dialog looks like:
And this is what the NX 8.5 Component Properties dialog looks like:
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.
RE: Expressions NX9: "IF" statements
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,
RE: Expressions NX9: "IF" statements
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
RE: Expressions NX9: "IF" statements
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
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
When you go to...
File -> Properties -> Attributes
...you'll find the following Attributes in a category titled 'User_Entry':
Blend = True
This is a Boolean Attribute controlling whether there is a blend on the model or not, using Suppress by Expression.
Blend_Radius = 10 mm
This is a 'List' Attribute offering ONLY three pre-defined Blend sizes. You MUST select one of the three choices.
Diameter = 100 mm
This is also a 'List' Attribute offering five different diameters for the cylinder, however in this case you have the choice of either selecting one of the five pre-defined sizes OR you can type in any size that you desire.
Height = 100 mm
And the last Attribute allows you to enter any desired value BETWEEN 50 and 200 mm.
Now all of these Attributes were set-up by using the tools found at...
File -> Utilities -> Attribute Templates...
...and creating what we call a 'Part File' template which means that it only effects the current part file. You can also create 'Catalogs' of attributes which can be available whenever you're creating a new part file even if you've never set up any pre-defined attributes for that part file template. Note that you do NOT need to use the Utilities -> Attribute Template... workflow if all you're doing is creating adhoc attributes on the fly, but you must go this route if you wish to set-up the various list or limits type attributes.
Anyway, I hope this helps you all better understand how attributes can be used to control many aspects of your models.
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.
RE: Expressions NX9: "IF" statements
But I'm playing around with creating my own "Diameter" Attribute like yours and falling down badly. How did you do that?
And your "Height" Attribute Shows a Range on the left side "Value" [50, 200]
How'd you do that one????
TIA
Dave
RE: Expressions NX9: "IF" statements
But how can I get those attributes to report to another attribute that passes info to the BOM??
That answer completes everything I've tried to accomplish in this thread and more.
TIA
DAve
RE: Expressions NX9: "IF" statements
Thanks for this all-saying-example.
I am currently located in a company, Attributes are used as a communication between purchasing/manufacturing and our CAD models.
Typical large assemblies of tubes, plates and fixation elements.
Attributes are highly used.
They/I use attributes since 11-12 years ago. But we are now in a process of streamlining the new capabilities of Attributes.
A bottleneck is the old CAD Data, which is mainly re-used (cloned), contains these old (STRING type)attributes but cannot be linked to expressions who are mainly NUMBER Type. This is logical, and we are hoping to have a simple and good working journal that finds and replaces the "old" attribute with the new style attributes.
I am sure this will be possible.
Currently a external User Function program (still NX6)is used to update all the Attributes, but it will be soon outdated, because of win64 bit converting problems.
This example perfectly shows the possibilities off the new Attribute type.
And as you explained, I have to set up Attribute Templates, this is the way to go!
Many thanks.
Pascal
OFF TOPIC Closer living to Brugge then the Antwerp guy, so do you know any name from your mothers side?
Maybe they can be tracked...
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
And can we use conditionals "IF" with constraint assemblies?
That could be useful for example with a Rubik cube, you would only allow some rotations when the perpendicular rotations are exactly a multiple of 90 degrees.
RE: Expressions NX9: "IF" statements
But speaking of NX and 'Rubik Cubes':
http://www.youtube.com/watch?v=ldLh7L6ib1Q
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.
RE: Expressions NX9: "IF" statements
These (4) are the source
Attributes = Model Tonnage Stroke Mtg Options
Type = String String String String
Values = LJ 500 050 B21
This is the target attribute and it should appear like:
BOM_CAT_NO = LJ.500.050.B21
But I can't even get this far this morning. I'm failing to pull together all I've learned at the modeling level. As you can see from above I'm using "string" attributes with numeric inputs and that's tripping up my expressions. I'm using "string" because the "number" type was drop the trailing zeros after the decimal point and its confusing. This method will be more flexible if I can get it working.
Maybe I'm trying to do something that wont work at all. This expression syntax is accepted but defaults to the "wrong entry" size.
if (Attr_Tonnage=300)(38) Else (if (Attr_Tonnage=500)(44.5) Else (if (Attr_Tonnage=750)(50) Else (Wrong_Entry)))
Do I need to convert that string data to a number first to be able to do this? I see you mentioned that above.
I've attached a screen dump in case it helps.
I'm going to keep working on this till it's solved. Hope I'm not wearing you out!
TIA Dave
RE: Expressions NX9: "IF" statements
Just need to create (1) Attribute from the (4) as shown in previous post.
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
Thanks so much for all the help and have a great holiday!!!
Dave
RE: Expressions NX9: "IF" statements
Attribute, Tonnage (Dia) / Attribute , Stroke(Length)
These two combine to form the basic size of the part. But all the selections in the "list" for "Stroke" don't go with every selection in the list for "Tonnage"
I designed the expression architecture to avoid the possibility of building a model that isn't commercially available. I needed to do that.
But the Error fallout leaves the user hanging.
Is there any practical way to deal with that?? Can I get my own message to appear??? "Choose a Compatible Stroke" or something. I'm definitely stretching I know.
Maybe I should have combined those two attributes into one. I had it that way on the pilot part I did first but I abandoned it. The possible attribute "list" was sooooo long and so were all the expressions.
TIA
Dave
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
I don't have a matrix to show how all this is put together, I kinda winged it all. But, I exported the expression list and included it as an attachment here.
I'm willing to re-construct the whole thing if there is a better architecture. This is the first of about 6 part families and I want to get it right.
Thanks
Dave
RE: Expressions NX9: "IF" statements
Could it be done with GRIP or NX ? (I mean a macro that modifies the constraints depending on conditions).
RE: Expressions NX9: "IF" statements
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.
RE: Expressions NX9: "IF" statements
Anyway, I have an idea which could extensively reduce the number and complexity of your 'IF' statements, but first a question. It would appear that there are THREE basic sizes of whatever that you're doing based on 'tonnage', 300, 500 and 750, correct?
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.
RE: Expressions NX9: "IF" statements
Anyway, take a look as this can save you a lot of complexity once you learn how to use 'List' expressions and then use the 'nth' function to pull values from these lists.
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.
RE: Expressions NX9: "IF" statements
This is a much improved format and really condenses things. It will take me a some time to break it down to the point where I can write my own stuff tho and I may have some questions.
First on the list is whether or not I can control the presented "list" options for the "stroke" attribute based on the selection for "tonnage"?
I can see that this is a hurdle that I'm going to see a lot more more of.
Dave
RE: Expressions NX9: "IF" statements
I think I can answer my own question and say no to the above question.
From the reading I did over the weekend it looks as if I may need to use KRX files to get that type of control.
Am I barking up the right tree???
Dave
RE: Expressions NX9: "IF" statements
Anyway, I've tried to provide you with a better idea of the Attribute and Expression options that NX now has (starting with NX 8.0) as this will provide you with a more complete set of tools going forward. Have fun...
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.
RE: Expressions NX9: "IF" statements
The last example is something I'm going to attempt to build on rather than delve into yet deeper water with KRX. I do actually have to get things done sooner or later!
I'll just have to put a limit on how much expand-ability to offer without being able to dynamically alter the select able options.
I'm thinking I may try to activate a suppressed feature like a "box" when a bad combination of tonnage and stroke is used. And I do have the caveats listed in the Stroke attribute.
All good. Have a great holiday.
Dave
RE: Expressions NX9: "IF" statements
I'm having a units problem with the "list expression" that I can't seem to pin down. (See Attached expression list)
Expressions BODY_Length & STROKE come out 25.4 times longer than they should while DIA_Body & DIA_Piston are working as designed.
I used your "Expression_List_Example_for_3dr" as the foundation for everything and it has worked beautifully other than this quirk. Which I've been able to compensate for with a multiplier.
I've realized that I can just switch the units of the expression and not need to use that on everything the way I have. But I don't want to go back and rework any of it till I figure this piece out. It's been vexing me for days.
Can you point me in the right direction??
TIA
Dave
RE: Expressions NX9: "IF" statements
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.