Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

EXPLODING PATTERNS WITH ILOGIC? HERE IT IS!

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
LOONYLEN
1261 Views, 2 Replies

EXPLODING PATTERNS WITH ILOGIC? HERE IT IS!

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 it's basic form.

If you do not have the pattern that is named in the code, in your assembly, you will get an error.

 

Senior Designer/Cad Administrator
Inventor 2012, w/SP2
Vault Collaboration 2012
Dell Precision T3500, Intel Xeon CPU
W3680 @3.33GHz, 16.0 GB of RAM
Microsoft Windows 7 Pro, 64 Bit Edition
Version 2009, w/SP1
2 REPLIES 2
Message 2 of 3
mrattray
in reply to: LOONYLEN

You didn't post any code.
Mike (not Matt) Rattray

Message 3 of 3
LOONYLEN
in reply to: mrattray

D'oh!

 

Sorry about that, here it is.

 

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

oPattern.Delete

 End Sub

 

It is a very simple code. Like I said though, You will need to add some things to it like "Check if there's a pattern, then run or don't run". You can experiment with the code and then post what you've learned back here for everyone to enjoy.

 

Thanks,

 

Len

Senior Designer/Cad Administrator
Inventor 2012, w/SP2
Vault Collaboration 2012
Dell Precision T3500, Intel Xeon CPU
W3680 @3.33GHz, 16.0 GB of RAM
Microsoft Windows 7 Pro, 64 Bit Edition
Version 2009, w/SP1

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report