Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Attributes and expressions 1

Status
Not open for further replies.

Michel1978

Mechanical
Nov 12, 2008
125
Hi,

How can I link the attributes with the expressions?

I would like to make an attribute "Length" which has to refer to an expression with the length value. This attribute i will use in my partslist.
So, what function do i need?

Michel
 
Replies continue below

Recommended for you

Michel,

1. In your part, let us say you have a parameter, called 'length_value' with value = 20 mm.

length_value = 20 mm


2. If you want to end up with a Part Attribute 'Length' with a value equal to the length_value, do the following: Create a new expression, call it 'length_attribute', and use the NX function ug_setPartAttrValue() as follows:

length_attribute = ug_setPartAttrValue("Length",format("%f",length_value))

Now you can double check in your Part Attributes; you should now have an Attribute titled 'Length', with a value equal to 20.000000.

The fact that this Attribute has six decimal places bugs me, and I don't know how to avoid it. Maybe someone else has a simple solution to this? (How to make the resulting value have an arbitrary number of decimal places, such as 20 or 20.00 etc?)
 
Thank you very much, it works. Only the zeros behind the dot is not nice indeed. Hopefully someone has a solution for that.
Is there somewhere a list of functions in the help by the way?
 
For a fist of functions, while in the Expression Dialog go to the bottom-left and select the icon which is labeled 'f(x)'. You will be able to get a list of the various classes of functions and then for each class a list of functions and with each function there is a brief description or you can select the '?' button and get a more complete description alone with examples.

John R. Baker, P.E.
Product 'Evangelist'
NX Design
Siemens PLM Software Inc.
Cypress, CA

To an Engineer, the glass is twice as big as it needs to be.
 
It works to recall an attribute in a partslist but I don't know how to recall it in a tabelar note or just some text.
I thought the same function should do it, but not.

I don't know either where the style of the partslist is stored. every time I have to change the celstyle.
 
Potrero,

For two decimal places use
ug_setPartAttrValue("Length",format("%0.2f",length_value))

For no decimal places use
ug_setPartAttrValue("Length",format("%0.0f",length_value))


Regards, Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor