MACRO LIBRARY

Toggle sheet metal flat pattern on and off

Free public access. No account or subscription required.

Files

Toggle sheet metal flat pattern on and off

Code

'Demonstrates how to locate and toggle on/off a flat pattern in a sheet metal part or an _
    assembly containing a sheet metal part named "Part1"
    
'Preconditions: part is open
'Results: if flat pattern is found, it is toggled on and off
    
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
    
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swAssy As SldWorks.AssemblyDoc
Dim swComp As SldWorks.Component2
Dim swFeat As SldWorks.Feature
    
Sub main()
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    
    'For use in an assembly (un-comment the next 3 lines, comment out the 4th line)
    'Set swAssy = swModel
    'Set swComp = swAssy.GetComponentByName("Part1-1")
    'Set swFeat = swComp.FirstFeature
    Set swFeat = swModel.FirstFeature
    While Not swFeat Is Nothing
        If swFeat.GetTypeName2 = "FlatPattern" Then
            swFeat.SetSuppression2 swUnSuppressFeature, swAllConfiguration, Empty
            swFeat.SetSuppression2 swSuppressFeature, swAllConfiguration, Empty
        End If
        Set swFeat = swFeat.GetNextFeature
    Wend
End Sub