Retrieve dimension value by specifying dimension ID

Hi all

I'm looking for the command to use in my SolidWorks macro to retrieve in a variable the value of a dimension but as it is set (with the same number of decimal places) by specifying the dimension in the form "D1@Esquisse1@199999.SLDPRT".

If you have a solution to suggest to me, I thank you in advance.

 

Hello

You have to look at GetSystemValue2.

Iterate Through Dimensions in Model Example (VBA)

Thank you for your answer.

GetSystemValue2 returns 0.11092358101119 in meters while GetValue2 returns 110.92358101119 in mm, which is better, but how do you make the command return 110.92, respecting the "Unit Accuracy" choice defined in the dimension options?

And how do I define the name of the dimension ("D2@Esquisse1@@NomConfig@199999.SLDPRT") from which I want to retrieve the value?

Hello

To select the desired dimension, do the following:

        boolstatus = swModel.Extension.SelectByID2("D2@Esquisse1@199999.SLDPRT", "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
        Set swSelMgr = swModel.SelectionManager
        Set swDispDim = swSelMgr.GetSelectedObject6(1, 0)
        Set swDim = swDispDim.GetDimension
        Debug.Print swDim.GetValue2("") 'Insert config name between the ""


To display it with a value to 2 decimal places, you must apply a treatment to the returned value (SW returns the full actual value and not rounding it according to the parameters)