Attributes and expressions
Attributes and expressions
(OP)
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
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





RE: Attributes and expressions
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?)
RE: Attributes and expressions
Is there somewhere a list of functions in the help by the way?
RE: Attributes and expressions
John R. Baker, P.E.
Product 'Evangelist'
NX Design
Siemens PLM Software Inc.
Cypress, CA
http://www.siemens.com/plm
http://www.plmworld.org/museum/
To an Engineer, the glass is twice as big as it needs to be.
RE: Attributes and expressions
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.
RE: Attributes and expressions
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