AnsweredAssumed Answered

How to use macro to control configuration (code attached)?

Question asked by Jason Apple on Aug 21, 2018
Latest reply on Aug 21, 2018 by Attilio Colangelo

What I want is a macro to control all configuration to be set hide and show.

 

I have the following code, it prints out the name correctly for each configuration, but does not set the hide/show right.

 

Please help

 

 

 

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim Part As Object
Dim Doc As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Dim boolstatus As Boolean




Function InspectConfigurations(Doc As SldWorks.ModelDoc2)
    Dim params As Variant
    params = Doc.GetConfigurationNames
    Dim vName As Variant
    Dim Name As String
    Dim thisConfig As Configuration
    For Each vName In params
        Name = vName
        Set thisConfig = Doc.GetConfigurationByName(Name)
        Debug.Print "Name                      ", thisConfig.Name




        Debug.Print "------------------------------------------------------------------"
    Next vName
End Function
Sub main()
    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    Set Doc = Part
    Set SelMgr = Doc.SelectionManager
    Call InspectConfigurations(Doc)
    Dim params As Variant
    params = Doc.GetConfigurationNames
    Dim vName As Variant
    Dim Name As String
    Dim thisConfig As Configuration
    Debug.Print "Modifying the configurations..."
    For Each vName In params
        Name = vName
        Set thisConfig = Doc.GetConfigurationByName(Name)
        boolstatus = Part.EditConfiguration3(Name, "", "", "", 32)


    Next vName
    Debug.Print "------------------------------------------------------------------"
    Call InspectConfigurations(Doc)
End Sub

 

 

 

Outcomes