EXPLODING PATTERNS WITH ILOGIC? HERE IT IS!

EXPLODING PATTERNS WITH ILOGIC? HERE IT IS!

Anonymous
Not applicable
1,365 Views
5 Replies
Message 1 of 6

EXPLODING PATTERNS WITH ILOGIC? HERE IT IS!

Anonymous
Not applicable

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

0 Likes
1,366 Views
5 Replies
Replies (5)
Message 2 of 6

jdkriek
Advisor
Advisor

iLogic simplified - no need for the Sub

 

oDoc = ThisDoc.Document
oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item("Component Pattern 1:1")
For i = 2 To oPattern.OccurrencePatternElements.count
	oPattern.OccurrencePatternElements.Item(i).Independent = True
Next
oPattern.Delete
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 6

Anonymous
Not applicable

jdkriek: thank you for providing this code to help us out exploding patterens. I tried to run this code with an assebly and i keep getting an error message.

 

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

Any help would be great.

0 Likes
Message 4 of 6

Anonymous
Not applicable

This is the code i am running i forgot to add it:

 

Format:HTML Format Version:1.0 StartHTML:     165 EndHTML:    3172 StartFragment:     314 EndFragment:    3140 StartSelection:     314 EndSelection:     314
SyntaxEditor Code Snippet

oDoc=ThisDoc.DocumentoPattern=oDoc.ComponentDefinition.OccurrencePatterns.Item("Componet Pattern 1:1")Fori=2TooPattern.OccurrencePatternElements.countoPattern.OccurrencePatternElements.Item(i).Independent=TrueNextoPattern.Delete
0 Likes
Message 5 of 6

Anonymous
Not applicable

8wr_zj,

 

First of all, you have spelled "Component" incorrectly in your code (Componet).

Also, have you replaced the "Component Pattern 1:1", with the name of your component pattern?

The name of your component pattern and the name in the code must match.

 

If this corrects your issue, please give Kudos and mark this answer as "Solution accepted".

 

Thanks,

 

Len

Message 6 of 6

Anonymous
Not applicable

doh looks like fat fingered it.  Thank you for the help i got it to run great after i followed your direction.

0 Likes