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!

Expression Help Please

Status
Not open for further replies.

SiW979

Mechanical
Nov 16, 2007
804
I would like to create an expresion based on the following, but keeping it short as possible.

Expression 1: rod_dia
Expression 2: end_length

If the rod_dia is 20mm then the end length is 17.5mm
If the rod_dia is 25mm then the end length is 18.5mm
If the rod_dia is 30mm, 35mm, 40mm, or 45mm then the end_length is rod_dia-5mm
If the rod_dia is 50mm or 60mm then the end_length rod_dia-10mm

many thanks NX'ers

Best regards

Simon NX4.0.4.2 MP10 - TCEng 9.1.3.6.c - (NX7.5 native)


Life shouldn't be measured by the number of breaths you take, but by the number of times when it's taken away...
 
Replies continue below

Recommended for you

Simon,

I haven't typed out the entire expression, but you should get the concept :

if(rod_dia==20)17.5 else if(rod_dia==25)18.5 else rod_dia-10

Obviously, you maybe able to consider using this syntax :

if(rod_dia>=30&&rod_dia<=45)rod_dia-5 else 100

The very last 'else' needs to use a default value.

NX 6.0.5.3
Windows XP32
 
My suggestion:
define an intermediate expression, lets say rod_correction.

rod_correction= if(rod_dia<25) 2.5 else if (rod_dia<30) 6.5 else if (rod_dia<50) 5 else 10

now define length:
length=rod_dia - rod_correction

regards
Frank.
 
This all looks good, but I've yet to try it because my system is in the middle of importing the mother of step files. One thing I don't follow is what the == and && actually mean? why not just a single = or &?

Any explanation would be most appreciated.

Best regards

Simon NX4.0.4.2 MP10 - TCEng 9.1.3.6.c - (NX7.5 native)


Life shouldn't be measured by the number of breaths you take, but by the number of times when it's taken away...
 
The == is a relational operator to make a comparison the = is an assignment.
The && and the & in NX I think is the same thing, in other programing languages && is a relational operator AND, and the & is the same but it compares at bit level.

For example:
lets say:
A=4 (100 in binary)
B=2 (010) in binary)

(A && B) is true
(A & B) in NX is true, but in C (for instance) is 0 (false).

Regards
Frank.
 
if (rod_dia>45)(rod_dia-10)else((if (rod_dia>25)(rod_dia-5)else(if (rod_dia>20)(18.5)else(17.5))))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor