Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Text format problem

Status
Not open for further replies.

bbylls

Mechanical
Joined
Feb 11, 2011
Messages
163
Location
US
I was using NX5
In the expressions I had:
HEATER=ug_setPartAttrValue("DESCRIPTION",format("HEATER %.3f dia. x ",p0) + format("%.2f",p1))
p0=heater diameter=.625
p1=heater length=30.0
It was a cylinder representing a tubular heater in a mold.
The part attribute DESCRIPTION would be "HEATER 0.625 dia. X 31.00"
Now in NX8.5 the DESCRIPTION is "HEATER 15.875 X 787.40
The part is in inches but the description is coming out in millimeters.
Is this a bug or am I missing something?
Did they change how format works?
I work around it by: ug_setPartAttrValue("DESCRIPTION",format("HEATER %.3f dia. x ",p0/25.4) + format("%.2f",p1/25.4))
 
Are the length expressions defined in inches?
What part units are used in the file you are placing the note?

www.nxjournaling.com
 
Everything, all files are inches.
 
Yes, all units are in inches.
 
If you are using 8.5, create a string expression:
Description = format("HEATER %.3f dia. x ",p0) + format("%.2f",p1)

Then create a part attribute (of type string) and link it to this expression; no need to use ug_setPartAttrValue. It may even solve your problem...

www.nxjournaling.com
 
Also note that the format function can convert units for you.
Code:
format("HEATER %.3f dia. x ",p0, "units", "in") + format("%.2f",p1, "units", "mm")

www.nxjournaling.com
 
If you're running NX 8.5 I would replace the format functions with the new Attribute Expression functions.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Thank you cowski, this worked:
expression DESCRIPTION=format("HEATER Ø%.3f x ",p0,"UNITS","IN") + format("%.2f",p1,"UNITS","IN")
then linked it in the attributes.
John, not sure what you meant about replacing the format function with the new Attribute Expression functions.
Thank you all.
 
If you go to the...

File -> Properties -> Attributes

...dialog you'll now find an option to create Attributes linked to the value of an Expression, and while in the Expression dialog, you'll find an option to create an Expression linked to the value of either Part or Object expressions. These new routines have replaced the older 'KF' attribute routines (which still work but are no longer found under the f(x) icon). These create actual 'attribute' expressions which will update like any other expression automatically, something which did not always happen immediately when using the older 'KF' attribute functions.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Thanks John, appreciate the clarification.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top