Like a lot of things in iLogic, it's not hard to figure out once you know the API. That'll take some practice. Here's some code that should get you going. I've tried to build and comment the code in a way that help you use the parts of it in the future to build more tools. Let me know if it doesn't work for you or if you have questions.
Sub Main()
'Call The Sub w/ the True argument and it'll go all the way through the model tree
SuppressNonSheetMetalComps(ThisDoc.Document, True)
'Call the Sub w/ False or No extra argument, and it will only do the top level
SuppressNonSheetMetalComps(ThisDoc.Document)
End Sub 'Main
Sub SuppressNonSheetMetalComps(doc As AssemblyDocument, Optional recurse As Boolean = False)
'Loop through all components at the top level of the given document
For Each comp As ComponentOccurrence In doc.ComponentDefinition.Occurrences
'Ignore things that are already suppressed
If comp.Suppressed Then Continue For
'Determine what to do base on the Name of the component definition type
Select Case TypeName(comp.Definition)
'Ignore Sheet Metal and Virtual Components
Case "SheetMetalComponentDefinition", "VirtualComponentDefinition"
'If recursion is enabled, call this sub for the sub Assembly
Case "AssemblyComponentDefinition"
If recurse Then Call SuppressNonSheetMetalComps(comp.Definition.Document, recurse)
'Suppress everything Else
Case Else
comp.Suppress
End Select
Next comp
End Sub 'SuppressNonSheetMetalComps
If this solved your problem, or answered your question, please click Accept Solution.