Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

new to nx need some programming suggestion 4

Status
Not open for further replies.

godpaul

Automotive
May 4, 2014
119
Hi all, I am new to nx. To be short, my current goal is to create some rules that can be used to suppress/unsuppressed features.previously in inventor, iLogic can be easily used but I found that in nx I need to go through a lot of vb programming...


What I mean suppress/unsuppressed is that if a string AAA= "circle", then, disable an extrusion operation that uses a rectangular sketch AND enable extrusion operation that uses a circle sketch.

Do you have suggestion or recommendation I should go with?

Thank you :)
 
Replies continue below

Recommended for you

What version of NX are you using? BTW, what you're trying to do can be done inside the expression system and if you're running NX 8.0 or newer, there's a really slick way to do this by simply changing an Attribute (actually you can do it in older versions as well, just that starting with NX 8.0 it got a whole lot easier).

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.
 
I am using nx 8.5

Suppress/unauppress is just my short term goal

On inventor, we did a lot of rules based modeling using I logic. We wrote some vb code to ask inventor get all parameter from access. The dimensions tolerance is also controlled by inventor code.

I am trying to transform what I did to nx.

The headache part is I don't know where to start...

If you can provide sample code for example I mentioned earlier. I can start to go from there and try to get deep into it

Thanks again
 
OK, the attached model uses 'Suppress by Expression' to control the display of the extruded bodies, one a 'circle' and the other a 'Rectangle'. It's controlled by a Part Attribute found at...

File -> Properties -> Attributes

...named 'AAA'. Simpley change it from 'Circle' to 'Rectangle' to change which Extrude is suppressed and which is unsuppressed. The actual mechanism controlling this action are a pair of 'IF' statements, triggered by the value of the 'AAA' attribute, imbedded in the 'Suppress by Expression' expressions. You can see all of the relevant expressions by going to the...

Tools -> Expressions...

...and set the 'Listed Expressions' filter to 'Named'.

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=94e9a744-ffd0-4108-b2a8-02c0fe6bdee0&file=Suppress_by_Expression_example-JRB-1.prt
thank you Mr. John,

your example is very helpful, one more question, when you create the "AAA" string, how do you make it multiple values (a drop down style selection for "circle" and "rectangle"?

I try to create a string called "shape" and typed in value; circle, how to add another value "rectangle" like you did?


thank you
 
also, when i try to replicate what you did, more questions generated...

in the pictures, one is done by me and another was done by you, ho did you add the attribute? I also used external sketch to do extrusion, do that matter? because in real models, some sketchs may be referenced by another sketch, that's why i do all features using external sketch not internal one.


have so many questions right now but i thanks for your efforts

 
 http://files.engineering.com/getfile.aspx?folder=5c0c05e9-279b-42cf-9107-4f5e3ecbb6b8&file=my.PNG
You set-up these sorts of Attributes by going to...

File -> Utilities -> Attribute Templates...

...and when the dialog open, select the 'Part File' option at the top of the dialog. Now go to the definition section and select the 'Data Type', in this case 'String' and change the 'Constraint Type' to 'List'. Now enter, hitting return after each entry, the 'list' of valid 'string' values. Now if you want to force the user to select ONLY from this list and NOT allow him to enter something else, toggle ON the 'Enforce Constraints' option and enter one of the items from the 'List' that you just entered as the 'Default Value'. It does NOT have to be the first one, but this will be the default when the user goes to access this Attribute for the first time.

When you're done, hit OK and now return to...

File -> Properties -> Attributes

...and you will find this Attribute in the group labeled 'Unset'. Simply select it and either accept the default or select the desired value and hit Apply.

BTW, the above 'Attribute Template' procedure is how you can pre-define attributes in your Modeling or Drafting template files so that they are ready to be activated whenever needed without worrying about people misspelling attribute names are the values entered, or for what we did above, where you can set-up items where the ONLY values entered are ones that you've already defined ahead of time. Note that attributes defined in the 'Attribute Template' process are NOT actually in effect until you activate them by going to the 'Unset' section of the 'Properties' dialog and select one. Also note that if later on youu were to 'delete' one of these pre-defined attributes, they are not actually deleted, but rather are simply returned to an 'Unset' status where they will be available in the future if you wanted it to be active again.

Anyway, I hope this helps explain how you can set-up pre-defined attributes.

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.
 
thanks Mr. John,

I created an attribute according to your method AND learned that i need to click "Reference Part Attribute" button at the bottom of expression dialog.

now the last step which is how to create a name in the expression dialog which shows Suppression Status like you did in the file, looks like the name after Rec and Cir are created by NX..


thanks for your effort and time!!
 
 http://files.engineering.com/getfile.aspx?folder=1f984162-d6d1-417a-81f7-f6831101d759&file=yours.PNG
Those expressions were created automatically (I simply renamed them) when I used the...

Edit -> Features -> Suppress by Expression...

...function to create the Suppression logic. Note that a value of '1' means that feature is 'unsuppressed' while a value of '0' means the feature is 'suppressed'.

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.
 
Succeeded!!!!!!!!!!!!! I attach the model for you to review

thank you so so much, I tried to search a lot online and none of topic related to my questions.

a big thanks to you, mr. John.

now i can investigate several other things, like:

if a string call AAA = "1"
disable feature 2,3, enable 1
if a string AAA = 2
disable feature 3, enable feature 1 and 2
if a string AAA = 3
enable feature 1,2,3

you see how's thing going to be complex. but this what our modelling group is doing...
if you have commnet about feature suppression, your suggestion and advice will be appreciated :)
 
 http://files.engineering.com/getfile.aspx?folder=c2303fdd-b6bb-4d6a-9fd1-a13a168a1d8f&file=model1.prt
I have attached a demonstration for simple journal to enable applying rules for as many features as you want. My simple example part contains seven features (4 blocks and 3 cylinders). I have applied names to each features. I have also applied a suppression expression to each feature. The journal process first finds all suppression expressions in the work part. Just for your information I have listed out these expressions. I then suppressed all block features. If the feature naming is unique then any rules can be applied.

Hope this helps

Frank Swinkels


 
 http://files.engineering.com/getfile.aspx?folder=d32a6df1-a676-47a7-b3a9-5465f27a7688&file=FeatureSuppressionByCode.zip
OK, look at the example that I've attached below. This is a part with three extrude features: 1, 2, 3. And there is an attribute named 'AAA' which can be either a 1, 2 or 3. Based on your request that...

if a string call AAA = "1"
disable features 2,3, enable 1
if a string AAA = "2"
disable feature 3, enable features 1 and 2
if a string AAA = "3"
enable features 1,2,3


...I've set up the Suppress Expressions like before only this time I'm using a nested 'list' expression to produce in essence a 'truth table' representing the suppress/unsuppress status of the three extrude features based on value of the 'AAA' attribute.

Anyway, take a look at the part file and as before, if you open the Expression dialog and set the 'Listed Expression' option to 'Named' you'll find the relevant expressions, in this case there are only five, the three Suppression expressions (one for each extrude feature), the expression 'Supp' which is the nested 'list' expression or what I called a sort of 'truth table' and the last expression is the one which returns the value of the 'AAA' attribute.

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=5159c615-261e-4596-87e1-397c271b7860&file=Suppress_by_Expression_example-JRB-2.prt
thank you all,

after yesterday's Mr. John, help, i tried the experiment for
if a string call AAA = "1"
disable features 2,3, enable 1
if a string AAA = "2"
disable feature 3, enable features 1 and 2
if a string AAA = "3"
enable features 1,2,3

...using John Method, and it is successful :)

I will defeintly tried FrankSwinks and John's New method !

So escited to learn more things in short time with all your help.
 
Mr. John, your nested table can greatly reduce the amount of code...
with the first method you taught me, the code can be lengthy as there are 3 items need to be taken care of.
this is a nice trick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor