Make component of a pattern idependent then delete it

Make component of a pattern idependent then delete it

rhutchins
Enthusiast Enthusiast
466 Views
1 Reply
Message 1 of 2

Make component of a pattern idependent then delete it

rhutchins
Enthusiast
Enthusiast
I have the code for deleting a pattern in an assembly but what I would really like to do is make the components independent before I delete them, the code I have for deleting the pattern is below if any one can add to it so it will make the compents independent then delete the pattern that would be awsome, I find when working with large asseblies it starts to take a long time to make a pattern independent then delete it, however if I use the macro for deleting them it takes no time at all thats why I would like to add the make independent before deleting. Please Help!
Sub DeletePattern()

Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oDef As AssemblyComponentDefinition
Set oDef = oDoc.ComponentDefinition

Dim oCompPattern As OccurrencePattern
Set oCompPattern = oDef.OccurrencePatterns.Item(1)

oCompPattern.Delete

End Sub
0 Likes
467 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Here's some code that does it.

Public Sub ExplodePattern()
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oPattern As OccurrencePattern
Set oPattern = oDoc.ComponentDefinition.OccurrencePatterns.Item(1)

' Make each instance independent, skipping the first one since
' it was the input for the pattern and is treated differently.
Dim oElement As OccurrencePatternElement
Dim i As Integer
For i = 2 To oPattern.OccurrencePatternElements.Count
oPattern.OccurrencePatternElements.Item(i).Independent = True
Next

oPattern.Delete
End Sub
--
Brian Ekins
Autodesk Inventor API