Macro: Reading Odds

Hello

I'm looking to make a macro in which I check the k-factor of a sheet metal part.

for this I am trying to retrieve in my variable "Fk" the value of the dimension "D2@Tôlerie" of the document "piece1.sldprt" in its configuration "conf1"

Thank you for your help

Try this:

Note: Replace swConfig.Name with "conf1" if you want this config instead of the current one.

Option Explicit
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swConfig As SldWorks.Configuration
    Dim swDispDim As SldWorks.DisplayDimension
    Dim swDim As SldWorks.Dimension
    Dim Fk As Double
    Dim status As Boolean
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swConfig = swModel.GetActiveConfiguration
    status = swModel.Extension.SelectByID2("D2@Tôlerie", "DIMENSION", 0, 0, 0, False, 0, Nothing, 0)
    Set swDispDim = swModel.SelectionManager.GetSelectedObject6(1, -1)
    Set swDim = swDispDim.GetDimension
    Fk = swDim.GetSystemValue2(swConfig.Name)
    Debug.Print "facteur k = " & Fk
End Sub

 

1 Like

It's perfect! Thank you very much... I was at an impasse.

Thanks again