How do I deactivate all instances of a component in a pattern?

How do I deactivate all instances of a component in a pattern?

Anonymous
Not applicable
405 Views
1 Reply
Message 1 of 2

How do I deactivate all instances of a component in a pattern?

Anonymous
Not applicable

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?

 

0 Likes
406 Views
1 Reply
Reply (1)
Message 2 of 2

jdkriek
Advisor
Advisor

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 

 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.