View Single Post
  #4  
Old 09-09-2014, 07:20 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Multi language mass table

Quote:
Originally Posted by papadam View Post
Thank you so much! This works like a charm!
Excellent -- thanks!

Quote:
Originally Posted by papadam View Post
Another issue raises up. In the thread material density settings they write
Code:
:units '( nil    :lb   Nil)
I would like to enter the density in kg/m^3 but we use kg and mm. Because we are located in different countries it's not guaranteed that everybody always has the same unit settings. How can I get the script to work independantly of the user settings?

I tried
Code:
:units '( nil    :kg/:m^3   Nil)
which does not produce an error but also does not convert the units.
Density is a challenge, as it uses two units of measurement (mass and length). Modeling doesn't have a units definition for mass at the user level (it internally keeps everything in g/mm^3). This means that your logical table needs to be *created* with the values in user units.

Unit-related side note: Because Modeling doesn't automatically convert density units, I would recommend that you use a units field of nil or :number for the density field. The only reason for the units field is for automatic conversion of mass, length, and angle, as those are the units Modeling tracks. If you're not using one of those unit types in your logical table, you don't even need the :units line in your table definition.

OK, so back to the issue at hand: As I mentioned above, when you create (or modify the contents of) the logical table, you will need to have it populated with the values in user units. However, since Modeling tracks density in g/mm^3, the initial specification must be done in those units.

Perhaps the easiest way to do this is with the function sd-sys-to-user-units, which *does* allow you to convert density. If you want to convert in the other direction, use the function sd-user-to-sys-units.

So your contents line could include something like:
Code:
:contents `(("5052 Aluminum" ,(sd-sys-to-user-units :density .0027))
            ("A2 Tool Steel" ,(sd-sys-to-user-units :density .007861)))
This block uses the backquote/comma, though using (list ...) can make things a little more clear.

I hope this helps! Please let me know if you have any questions.

Thanks!

andy
__________________
Andy Poulsen
AI MAXTools: Dream. Design. Done. It's that easy!
Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+!
See them in action at www.ai-maxtools.com and then try them for yourself -- FREE!
Reply With Quote