Cancel
Showing results for 
Search instead for 
Did you mean: 

Using a lookuptable in UDF part

Pioneer
Pioneer

 

Dear Community

 

I want to create a UDF containing design templates for different bolting connections.

Since the Main diameter controls different parameters accordingly I'd like to create a comprehensive table/spreadsheet within this UDF part where the correct parameters will be read out to instance the UDF.

E.g. the main Diameter of a screw thread defines the different sections of the screw holes thread etc..

 

Has anybody done this ?

 

Greetings

 

 

 

 

_____________________________
Are you familiar with my product?
click here
8 REPLIES

Re: Using a lookuptable in UDF part

Phenom
Phenom

We have Sae ports  where we emphasize list of value depending on thread size.  Check out the expressions in the attached part.  This was done back in older version of NX.  So there maybe a look up function these days in the expression editor.  So this may be a bit old.

 

Here is a thread that discusses this in a different forum

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

 

 

 

 

Re: Using a lookuptable in UDF part

Siemens Legend Siemens Legend
Siemens Legend

The method below from sdeters is great.  Works like a charm.

 

Here is another thought/method to consider...  This will make sense in certain situations, and the other method will be more useful in other situations.  Consider it food for thought.  :-)

 

I've attached a simple example of using a List expression to embed a smallish "table" of data within the part, and then using an expression containing a loop to cycle through the table data until the appropriate value is found. 

 

Why would you use the loop instead?  Main thing is that it avoids the super-long if()then()elseif()then()elseif()then()elseif()then()elseif()then()else() kind of syntax, and adapts cleanly if you edit the data in the table.

 

Here, an expression called "BUSHING_OD" specifies the outer diameter of a bushing, and the "BUSHING CLEAR" expression represents a clearance value that varies based on specified ranges of the outer diameter value:

 

three expressions

 

As you can see above, each sub-list within the "tol_data" expression contains three values: the lower end of a range, an upper end to the range, and the clearance value for that range.  There are several ranges represented in this one expression.

 

With the NX 11 Expressions dialog, you can now edit list expressions -- including two-dimensional lists like this one (a list of lists, really) -- using a table-style UI that will allow you to cut and paste from Excel, if you like.  You can get into this mode using the "Change the method..." button in the lower left of the Edit dialog:

 

editing a list expression like a table

 

Pro Tip: While in this editor, you'll use MB3 menus on the row and column headings to add or remove rows and columns.

 

The loop in the "BUSHING_CLEAR" expression is the trickiest part here... 

 

the scary loop

 

Many of you will recognize this as Knowledge Fusion syntax -- the language underpinning NX Expressions.  Basically, this loop says that:

 

for each thing in the list "tol_data" (each sub-list, here)
if the "BUSHING_OD" is larger than the first item in the [sub]list, AND
the "BUSHING OD" is less than or equal to the second item in the [sub]list, THEN
return the third item in the [sub]list. 
And if you don't find any matches at all, return 999. 

 

...Which should be a signal to design the ranges better.  :-)

 

And again, the reasoning behind an approach like this is that the loop syntax would never need to change when the set of ranges is adjusted, and that the set of ranges can be edited far more easily in table form than in a big long if()then()else() construct.

 

Hopefully that all makes sense.  Enjoy!

Taylor Anderson
NX Product Manager, Knowledge Reuse and NX Design
Tel: +1 (602) 441-0683
taylor.anderson@siemens.com

Re: Using a lookuptable in UDF part

Valued Contributor
Valued Contributor

Wow, thats great.

But i guess this commands ("loop", "for", "list of lists", what else?) only work in NX11 or higher. Is this correct? I can't find them in my NX10. Also  I can't find a hint to them in the "What's New in NX11".

 

Wolfgang

Highlighted

Re: Using a lookuptable in UDF part

Phenom
Phenom

Although there is no support for the nice dialog to edit the list expression I got this to (almost) work in NX8.5.

The only thing I could not get to work was the default return value if the loop did not find a suitable entry. It came up with a syntax error for "Return 999;". If I simply left that out it worked, but the value of the loop expression was shown as "(Error)" if no valid entry was found.

I can definitely see uses for this kind of syntax and we are planning to migrate to NX11 this year so we'll get the full benefit then Man Happy

Graham Inchley Snr R&D Engineer (Systems Development), Sandvik Coromant
Lenovo ThinkPad W540, Win7, 16GB. Developing in: Java | C | KF
Production: [NX8.5.3.3 MP11 64bit] Testing: [NX12.0.0.27 MP1]

Re: Using a lookuptable in UDF part

Phenom
Phenom

Nice.   Will other type of loop Syntax work in the Expressions?  Or is knowledge fusion the only syntax?

 

Thanks

Re: Using a lookuptable in UDF part

Siemens Legend Siemens Legend
Siemens Legend

Inch --

 

You're right... the dialog is new in NX 11, but the syntax has worked since about NX 3.  :-)

 

...and that last bit will work great for you if you add an "is" in there:

 

Return is 999;

 

Ah, the joys of Knowledge Fusion syntax...  ;-)

 

--Taylor

Taylor Anderson
NX Product Manager, Knowledge Reuse and NX Design
Tel: +1 (602) 441-0683
taylor.anderson@siemens.com

Re: Using a lookuptable in UDF part

Siemens Legend Siemens Legend
Siemens Legend

FlightAssistOn --

 

>> But i guess this commands only work in NX11 or higher

 

It's not going to be in any of the recent What's New Guides...  This syntax has actually been available since about NX3 as part of Knowledge Fusion (which underpins expressions), but it's a bit advanced so we don't push it much.

 

But the Knowledge Fusion Help (in the Programming Tools Help) has great sections describing some fo the other programming elements that are available:

 

https://docs.plm.automation.siemens.com/tdoc/nx/11/nx_api#uid:index_fusion:id1395526

 

Not trivial stuff, but very powerful.  :-)

 

Does that help?

 

 

 

 

Taylor Anderson
NX Product Manager, Knowledge Reuse and NX Design
Tel: +1 (602) 441-0683
taylor.anderson@siemens.com

Re: Using a lookuptable in UDF part

Siemens Legend Siemens Legend
Siemens Legend

sdeters --

 

>>Will other type of loop Syntax work in the Expressions?  Or is knowledge fusion the only syntax?

 

KF is fundamentally the language underpinning Expressions, so you'll need to use the KF syntax.  If you want to get more into this, see the link in the post below to the Knowledge Fusion Help for programming elements like loops.

 

Hope that helps!

Taylor Anderson
NX Product Manager, Knowledge Reuse and NX Design
Tel: +1 (602) 441-0683
taylor.anderson@siemens.com