Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Extracting units from mass properties

Status
Not open for further replies.

PDMAdmin

Mechanical
Apr 21, 2004
488
0
0
US
I'm currently working on some custom properties that link to the mass properties, such as Volume, Density, etc. The problem is that some parts have different units, so it would be very helpful to put in a custom property that specifies what unit system is being used. (The mass property numbers are only scalar; the units are not included.)

Does anyone know of a way to do this? Thanks for the help.
 
Replies continue below

Recommended for you

I see what you're saying, but that's not really extracting the unit system from the mass properties. That's simply entering text into a custom property. What I'm after is a linked property that will reflect the current unit system being used, without me having to go and change it every time. I'm after something like "SW-Units@MyPart.SLDPRT" but the problem is that there's no such variable as "SW-Units."
 
You'll have to interrogate the object model (that is, use the API) to do what you want automatically. Check the APIHELP.CHM file, ModelDoc2::GetUserUnit and SetUserUnit.
 
It's been a while since I tried to use mass properties in a drawing. There were some problems that made me back off from the whole thing.

The units for mass properties is not controlled by the model units. It is controlled by the units settings in the mass properties tool. For instance, if the part units were millimeters, and I changed the mass properties tool units to inch, the mass would be in pounds.

This may have changed. Be careful and experiment thoroughly.

[bat]Due to illness, the part of The Tick will be played by... The Tick.[bat]
 
And another thing...

The "mass" property value is based on the model's current active configuration. If the drawing shows one configuration, but the part is open and has a different configuration active, the mass value will be that of the part's current active configuration.

[bat]Due to illness, the part of The Tick will be played by... The Tick.[bat]
 
The API evolves (sometimes varying by Service Pack) reflecting changes to the SW Object Model; precise answer to original question requires system specifics.

As of SW2003 SP2R11.0 Density is part of MassProperty object; System units are Meters, Radians, Grams, Seconds .. Property UseSystemUnits determines whether MassProperty object will use System Units or Document Units. MassProperty is a Utility object.

As Tick says,
Be careful and experiment thoroughly.
There is no substitute for validation (a.k.a. 'debugging').
 
After playing around with several different options (including "Volume in Feet" from Scott Baugh's website), I decided to stick with the automatic "unitless" properties and not mess with the API. I can display the units easily with the API (it helps that the API has its own standard set of units), but the price you pay is that the information doesn't update very frequently. (A geometry rebuild appeared to be the only reliable way, from what I saw.)

Thanks for all the help!
 
Status
Not open for further replies.
Back
Top