Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

compare number to list of numbers in expressions

Status
Not open for further replies.

multicaduser

Industrial
Jan 29, 2013
261
To keep it simple I would like to use expressions to find the smallest number in a list that is greater than an input.

1. The number to compare to a list is 35
2. The list of numbers: 22,28,32,37,42,57,63

The above example it would return 37 because that is the smallest number greater than 35.

What would be the best way to do this in expressions. The list will be constant but the input could be any real number.

tia

NX 2212 Windows 10
 
Replies continue below

Recommended for you


Good morning,

1. Create an expression for your parameter : Number = 35
2. Create a list of values : List = {22;28;32;37;42;57;63}

3. Create an expression for your result : Result = loop{for $val in List;if(Number=<$val)return $val;return is 0;}


The result of the expression will be 37.
 
Morning El Paben, thanks for the reply. Sorry I forgot to mention this needs to be done in the expression editor within NX, excel and journaling are not options. For right now a brute force method was used, which requires a little more work for updates. The result of the comparison is then used to drive other expressions.

Here is a little snip of the brute force comparison.

"if(force_required<=nth(1,cylinder_pressure))1 else if(force_required<=nth(2,cylinder_pressure))2 else if"...



NX 2212 Windows 10
 
multicaduser said:
Sorry I forgot to mention this needs to be done in the expression editor within NX

El Paben's solution is intended to be used in the expression editor. It makes use of an "undocumented feature" of the expression system. For a more thorough explanation, see Taylor's post in thread561-412524.

www.nxjournaling.com
 
Hi cowski, thanks for the update, will have to look at it later. Often wondered if there was a listing of undocumented NX features.

NX 2212 Windows 10
 
LOL yup, perhaps an unofficial list? wink wink

NX 2212 Windows 10
 
Wow, how slick. Still trying to figure out "HOW" it works (as a non-programmer I have an idea), and now am curious if this will go away because it is undocumented. Don't want to build on something if it will go away.

NX 2212 Windows 10
 
Can you please show us what you end up doing.

Jerry J.
UGV5-NX1899
 
Basically what El Paben showed in his post (again awesome help).


force_required = 240.9264
pressure_list = {155,235,368,530,721,942,1192}
force_answer = loop{for $val in pressure_list;if(force_required=<$val)return $val;return is 0;}


I'm getting closer to retirement and am building intelligence into the tool models to help guide a nubie. Parameter tables are used to select from some standard requirements to calculate the result with images of documentation on a separate layer in the file for clarification.

Guess I'm building my own obsolescence.

NX 2212 Windows 10
 
The loop is using Knowledge Fusion (KF) commands. The expression system is built on KF, so I doubt it is going away anytime soon.

www.nxjournaling.com
 
I suspect that the term 'undocumented' is misleading because of exactly what cowski said. The Expression system supports Knowledge Fusion routines, which I think you'll find IS documented, just that when looking at the documentation for the Expression system, you're NOT going to see anything about individual KF routines, just, at best, a comment about them being supported. What this means is that the 'documentation' can be found in the Knowledge Fusion section.

John R. Baker, P.E. (ret)
Irvine, CA
Siemens PLM:

The secret of life is not finding someone to live with
It's finding someone you can't live without
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor