I have a few components in my assenbly that I want to turn off under certain conditions. Using Component.IsActive, I can turn on or off an instance, but some of the components are in a pattern, and I want to turn on or off all instances of the component. To add to the challenge, the component patters are driven from Excel, aand the quantity of parts changes.
How can I turn off all of the instances of a pattern?
This is a method for suppressing all the occurrences within a pattern. In this example, we are looking at one single pattern, but in reality for your needs (im assuming) you would need to iterate over all patterns or at least use the selected pattern, then iterate over all occurrences of the component within those pattern(s) and suppress it. If you cannot derive how to do this from the example, I'll help you.
Public Sub SupressOcc() Dim oDoc As AssemblyDocument Set oDoc = ThisApplication.ActiveDocument Dim oPattern As OccurrencePattern Set oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item("PatternName") Dim oPatternElement As OccurrencePatternElement For Each oPatternElement In oPattern.OccurrencePatternElements Dim oOcc As ComponentOccurrence For Each oOcc In oPatternElement.Occurrences oOcc.Suppress Next Next End Sub