Macro to change suppressed parts into envelope parts

Have a need to run a macro in one of my complex assemblies, that will find and change all of the currently suppressed parts into envelope components.

Hopefully someone can help. Thank you in advance!

Top level parts only or parts in subassemblies as well?

Hi Jim,

Top level parts only.

Leave them suppressed after changing to envelope or unsuppress them?

leave them suppressed. - thanks. Sorry for the delay - was in a meeting.

Exclude from BOM?

Correct

I think this will do it:

Option Explicit

Dim swApp As SldWorks.SldWorks
Dim mDoc As ModelDoc2
Dim aDoc As AssemblyDoc
Dim activeConfig As Configuration
Dim rootComp As Component2
Dim vChildren As Variant
Dim selMgr As SelectionMgr
Dim boolStatus As Boolean
Sub main()
    Set swApp = Application.SldWorks
    Set mDoc = swApp.ActiveDoc
    If mDoc.GetType <> swDocASSEMBLY Then
        Exit Sub
    End If
    Set aDoc = mDoc
    Set selMgr = mDoc.SelectionManager
    Dim configNames As Variant
    Dim configIndex As Integer
    configNames = mDoc.GetConfigurationNames
    Dim nextConfig As Configuration
    For configIndex = LBound(configNames) To UBound(configNames)
        Set nextConfig = mDoc.GetConfigurationByName(configNames(configIndex))
        mDoc.ShowConfiguration2 configNames(configIndex)
        Set rootComp = nextConfig.GetRootComponent3(False)
        vChildren = rootComp.GetChildren
        Dim i As Integer
        Dim nextChild As Component2
        For i = LBound(vChildren) To UBound(vChildren)
            Set nextChild = vChildren(i)
            If nextChild.GetSuppression2 = swComponentSuppressed Then
                Dim selData As SelectData
                Set selData = selMgr.CreateSelectData
                boolStatus = nextChild.Select4(False, selData, False)
                boolStatus = aDoc.CompConfigProperties6(swComponentSuppressionState_e.swComponentSuppressed, nextChild.Solving, True, False, "", nextChild.ExcludeFromBOM, True, swASMSLDPRTCompPref_e.swUseSystemSettings)

            End If
        Next i
    Next configIndex
End Sub


Thanks Jim! I will give it a try and report back.

Works great for the active configuration, all suppressed parts change to envelopes as expected. The trouble is I have about 350+ configurations in this assembly. With no method of controlling envelopes via design table, I was hopeful a macro could save me from having to activate each one individually to change these parts.

Any chance it could cycle through all configurations / derived configurations and perform the same behavior?

I updated the code above to cycle through the configs. It will have to activate each config to do the work.

Can’t thank you enough Jim, works just like I had hoped. :+1:

Something I’ll probably have to let run overnight, based on my test it doesnt appear to be something I’ll want to wait on to finish.