×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX CONDITIONAL LOGIC STATEMENTS
5

NX CONDITIONAL LOGIC STATEMENTS

NX CONDITIONAL LOGIC STATEMENTS

(OP)
I am trying to write a conditional statement to control bushing clearance size, based on bushing OD.
There are difference clearance requirements for different diameter bushings.
NX 8.5 if that makes a difference.
Below is the information:

Range_____clearance
0-3mm____0.010mm____________1
3-6_______0.012_______________2
6-10______0.015_______________3
10-18_____0.018_______________4
18-30_____0.021_______________5
30-50_____0.025____TOLERANCE_6
50-80_____0.030_______________7
80-120____0.035_______________8


expressions are set at:
"BUSHING_OD"____30
"TOLERANCE_6"___0.025

So this is what I have so far which works as intended:
"BUSHING_CLEAR" = IF((BUSHING_OD>=30)&&(BUSHING_OD<50))THEN(TOLERANCE_6)
"BUSHING_CLEAR" = IF((BUSHING_OD>=50)&&(BUSHING_OD<80))THEN(TOLERANCE_7)
"BUSHING_CLEAR" = ETC.....

What I want to do is CONNECT multiple if/then/else statements under the expression "BUSHING_CLEAR"
How do I connect multiple conditional statements together, is it possible?
Everything above 120mm should be set at TOLERANCE_8



RE: NX CONDITIONAL LOGIC STATEMENTS

(OP)
I tried doing this below, which did not work, syntax error.
"BUSHING_CLEAR" = IF((BUSHING_OD>=30)&&(BUSHING_OD<50))THEN(TOLERANCE_6)ELSE(IF(XXXXXXXX)THEN(xxxxxxxxx)ELSE(0))

That this is the idea I am trying to do, if it's possible

RE: NX CONDITIONAL LOGIC STATEMENTS

IF((BUSHING_OD>=30)&&(BUSHING_OD<50))THEN(TOLERANCE_6) else if ((BUSHING_OD>=50)&&(BUSHING_OD<80))THEN(TOLERANCE_7) etc ending with a final else for the last condition.

Is that what you're looking for?

NX9.0.3.4 MP1/Windos 7 Service Pack 1

RE: NX CONDITIONAL LOGIC STATEMENTS

oops....just a little messed up

IF((BUSHING_OD>=30)&&(BUSHING_OD<50))TOLERANCE_6 else if ((BUSHING_OD>=50)&&(BUSHING_OD<80))TOLERANCE_7 else TOLERANCE_8

NX9.0.3.4 MP1/Windos 7 Service Pack 1

RE: NX CONDITIONAL LOGIC STATEMENTS

(OP)
Yes! That worked, I could not get it formatted correctly to work thank you!

RE: NX CONDITIONAL LOGIC STATEMENTS

(OP)
Here it is working in all it's glory!

if((BUSHING_OD_IPE>=0)&&(BUSHING_OD_IPE<3))H7_BORE_TOLERANCE_1 else if((BUSHING_OD_IPE>=3)&&(BUSHING_OD_IPE<6))H7_BORE_TOLERANCE_2 else if((BUSHING_OD_IPE>=6)&&(BUSHING_OD_IPE<10))H7_BORE_TOLERANCE_3 else if((BUSHING_OD_IPE>=10)&&(BUSHING_OD_IPE<18))H7_BORE_TOLERANCE_4 else if((BUSHING_OD_IPE>=18)&&(BUSHING_OD_IPE<30))H7_BORE_TOLERANCE_5 else if((BUSHING_OD_IPE>=30)&&(BUSHING_OD_IPE<50))H7_BORE_TOLERANCE_6 else if((BUSHING_OD_IPE>=50)&&(BUSHING_OD_IPE<80))H7_BORE_TOLERANCE_7 else if((BUSHING_OD_IPE>=80)&&(BUSHING_OD_IPE<120))H7_BORE_TOLERANCE_8 else H7_BORE_TOLERANCE_8

RE: NX CONDITIONAL LOGIC STATEMENTS

Shorter version:

CODE

IF(BUSHING_OD>=80)(TOLERANCE_8)ELSE(IF(BUSHING_OD>=50)(TOLERANCE_7)ELSE(IF(BUSHING_OD>=30)(TOLERANCE_6)ELSE(IF(BUSHING_OD>=18)(TOLERANCE_5)ELSE(IF(BUSHING_OD>=10)(TOLERANCE_4)ELSE(IF(BUSHING_OD>=6)(TOLERANCE_3)ELSE(IF(BUSHING_OD>=3)(TOLERANCE_2)ELSE(TOLERANCE_1))))))) 

www.nxjournaling.com

RE: NX CONDITIONAL LOGIC STATEMENTS

I like the version from cowski better for your requirements. The "else if" works well for odd comparisons that don't go in such a linear manner. Great timing though, the shorter version will work well for a few expressions I'm writing right now.

NX9.0.3.4 MP1/Windos 7 Service Pack 1

RE: NX CONDITIONAL LOGIC STATEMENTS

(OP)
Awesome, I agree that shorter version is better. Learning everyday smile

RE: NX CONDITIONAL LOGIC STATEMENTS

There might be some additional refinement that could be done using 'List Expressions' and the 'nth' function.

Here are a couple of threads where the 'List Expression' is discussed and examples provided:

http://www.eng-tips.com/viewthread.cfm?qid=364292

http://www.eng-tips.com/viewthread.cfm?qid=402217

http://www.eng-tips.com/viewthread.cfm?qid=370644

John R. Baker, P.E. (ret)
EX-Product 'Evangelist'
Irvine, CA
Siemens PLM:
UG/NX Museum:

The secret of life is not finding someone to live with
It's finding someone you can't live without

RE: NX CONDITIONAL LOGIC STATEMENTS

4
So, just for fun, and since John mentioned the "list" and "nth" functions, here's the solution to which he's alluding:

You can actually put all of these range values and tolerance values in a single list expression, like this:

CODE --> Expressions

{
{0, 3, 0.01}, 
{3, 6, 0.012}, 
{6, 10, 0.015}, 
{10, 18, 0.018}, 
{18, 30, 0.021}, 
{30, 50, 0.025}, 
{50, 80, 0.03}, 
{80, 120, 0.035}
} 

Prior to NX 11, this is most easily done using the little "Extended Text Entry" button on the right end of the Formula field:



...and in NX 11, we'll get you away from the curly brackets and commas with the ability to directly edit the data in this list expression like a table:



And yes, I just copied-and-pasted that data into the expression edit dialog directly from Excel. We think you're going to like being able to do that. smile

But anyway, the other trick is crafting an expression to "look up" the right tolerance value from the table. And that's where the concept of lopping through the list comes in really handy. Here's the formula for a BUSHING_CLEAR expression:

CODE --> Expressions

loop {
for $set in tol_data;
If ( ( BUSHING_OD > nth(1,$set) ) && ( BUSHING_OD <= nth(2,$set) ) ) Return nth(3,$set);
Return is 999;
} 

Again, this is most easily done in the "Extended Text Entry" mode, rather than trying to set it all up in a single line. The "Extended Text Entry" will preserve any formatting you introduce, and make it much easier to come back and edit this later.

Now... for the interested student, this is a case where it's handy to have the Knowledge Fusion language lurking underneath NX Expressions.

1. The first line inside this loop cycles through each "set" of values in a list expression called "tol_data".

2. In the "if" statement line, it checks to see if the BUSHING_OD is larger than the first number in the "set" AND less than or equal to the second number in the set, and if this is true, returns the third value in the set (the appropriate tolerance value) and then exits the loop.

3. The last "Return" line returns a default value of 999 if the BUSHING_OD is outside the range of the data in the table. That's just a failsafe, to make sure you've got a number coming back every time.

And so the loop returns one clean number, every time.

In the end, this setup results in a total of three expressions... One for the BUSHING_OD, one list expression for all of the tol_data, and the output expression BUSHING_CLEAR:



...and if you want to add more rows to the table, that's FAR easier than trying to wedge more IF()THEN()ELSE() statements into an expression, right?



...and with the exception of the table-based editing of the list, all of this is possible in any version since NX 8.5, when we introduced the List expression type.

Does that help? smile

Taylor Anderson
NX Product Manager, Knowledge Reuse and NX Design
Product Engineering Software
Siemens Product Lifecycle Management Software Inc.
(Phoenix, Arizona)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources