Document Manager: change unit of measure of GetMassProperties

Hi,
I’m trying to use the Document Manager API to get the model mass properties in an Excel file. I’m using the GetMassProperties method that returns values in MKS unit system.

Is there a way to change the unit of measure, say for example from meters to millimeters?

I tried to apply the scale factor in the VBA code but it seems that the method returns just two decimal places.

Dim swDmApp As SwDocumentMgr.SwDMApplication
Dim swDmDoc As SwDocumentMgr.SwDMDocument10

Set swDmApp = ConnectToDm()
Set swDmDoc = OpenDocument(swDmApp, fileName, True)

Dim swDmConf As SwDocumentMgr.SwDMConfiguration10
Set swDmConf = swDmDoc.ConfigurationManager.GetConfigurationByName(confName)

Dim massPrps As Variant
Dim bRet As SwDmMassPropError

massPrps = swDmConf.GetMassProperties(bRet)

Thanks in advance.

Hi @andrMollo, the Document Manager API appears to use the document setting for decimal places with this function. If you have this value set to 2, then all values will return with 2 decimal places. This is essentially going to display the data with the same decimal places as the (Evaluate → Mass Properties) tool within the Solidworks GUI. You will have to do your own unit conversion if you don’t want the returned units of meters and kilograms, though.

image

Hi @BigCrazyAl ,
thanks for the answer. Since I work in millimeter the only way I see to get meaningful number from this method is to change this document setting.

Are you aware of a method to change the documents units by the Document manager API? I only find a way to get them (GetSwDmSettingInteger), not to set / change them.

Unfortunately, the Document Manager API is limited in the things it can change in a document. Either the user would have to open a document in Solidworks and manually modify or used Solidworks API to modify the document units and decimal places.

1 Like