You can use UnitsOfMeasure object to convert values from one unit system to
another. For example:
Public Sub GetPartMassProps()
' Set a reference to the part document.
' This assumes a part document is active.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' Set a reference to the mass properties object.
Dim oMassProps As MassProperties
Set oMassProps = oPartDoc.ComponentDefinition.MassProperties
' Set the accuracy to medium.
oMassProps.Accuracy = k_Medium
MsgBox "Volume: " & oMassProps.Volume
MsgBox "Volume (in^3): " &
oPartDoc.UnitsOfMeasure.ConvertUnits(oMassProps.Volume, "cm cm cm", "in in
in")
MsgBox "Volume (mm^3): " &
oPartDoc.UnitsOfMeasure.ConvertUnits(oMassProps.Volume, "cm cm cm", "mm mm
mm")
End Sub
wrote in message news:5200285@discussion.autodesk.com...
HI,everyone.
How can i format the volume of the code bellow to be displayed in mm^3 and
m^3 ?
Public Sub GetPartMassProps()
' Set a reference to the part document.
' This assumes a part document is active.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' Set a reference to the mass properties object.
Dim oMassProps As MassProperties
Set oMassProps = oPartDoc.ComponentDefinition.MassProperties
' Set the accuracy to medium.
oMassProps.Accuracy = k_Medium
MsgBox "Volume: " & oMassProps.Volume
end sub
Thanks.