EXPLODING PATTERNS WITH ILOGIC? HERE IT IS!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys,
I was searching for a way to "explode" patterns using an iLogic rule.
I did some researching and came across an old post by Brian Ekins from 2008.
He had written some code to "explode" component patterns for the API.
I tweaked it a bit and got it to work inside of iLogic. It really works!
It's also very simple. Just a brief description of what the code does.
We start at element #2, because element #1 is the patterning component.
We count the number of elements in the pattern, then make them independent.
Making them independent, suppresses them in the pattern AND copies them to the design tree.
Then we simply delete the pattern sending the patterning component (element #1) into the design tree as well.
This code is in its basic form.
If you do not have the pattern that is named in the code, in your assembly, you will get an error.
I'm working on adding a "Don't run if you don't find the pattern" section to the code.
For now, you can use this as a starting point.
Code:
Sub Main() ExplodePattern
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oPattern As OccurrencePattern
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item("Component Pattern 1:1")
'MAKE EACH ELEMENT INDEPENDENT, STARTING AT THE SECOND ELEMENT.
Dim i As Integer
'COUNT HOW MANY ELEMENTS ARE IN THE PATTERN, AFTER 2
For i = 2 To oPattern.OccurrencePatternElements.Count
'MAKE ALL ELEMENTS INDEPENDANT
oPattern.OccurrencePatternElements.Item(i).Independent = True
Next
'DELETE THE PATTERN, LEAVING ONLY THE INDEPENDENT COPIES AND THE ORIGINAL ELEMENT
oPattern.Delete
End Sub