Retrieve density value by macro

Hello
I want to use swMaterialPropertyDensity, but the macro doesn't return the value, but systematically 7 regardless of the material.
isn't there a story of Val() value??
Thank you for enlightening me...
 

 

Hello

 

Sharing your macro will help so that more people respond to you

Cdlt

I found this to work:

variable = swDrawModel.GetUserPreferenceDoubleValue(swUserPreferenceDoubleValue_e.swMaterialPropertyDensity)

It returns the value of the density of my piece contained in its drawing.

If it can be useful...

1 Like

Hello

Try this:

Option Explicit
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Dim swMprop As SldWorks.MassProperty
    Set swMprop = swModel.Extension.CreateMassProperty
    Debug.Print "get density - 1st method: " & swMprop.Density
    Debug.Print "get density - 2nd method: " & swModel.GetUserPreferenceDoubleValue(swMaterialPropertyDensity)
End Sub

 

2 Likes