Message 1 of 3
Model explosion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've a code for explode an assembly but actually all the Patterns are deleted. I'd like to not delete the patterns but if I remove the delete command the rule keep working in loop.
Sub main
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oPane As BrowserPane = oDoc.BrowserPanes.Item("Model")
Dim oOccs As ComponentOccurrences = oDef.Occurrences
ReturnStep :
For Each oOcc As ComponentOccurrence In oOccs
Dim oRefDoc As Document = oOcc.Definition.Document
If oRefDoc.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject _
Or Not oRefDoc.IsModifiable Then Continue For
Dim oTargetNode As BrowserNode = oPane.GetBrowserNodeFromObject(oOcc)
For Each oSubOcc As ComponentOccurrence In oOcc.SubOccurrences
Dim oSourceNode As BrowserNode
oSourceNode = oPane.GetBrowserNodeFromObject(oSubOcc)
Try : Call oPane.Reorder(oTargetNode, True, oSourceNode) : Catch : End Try
Next
oOcc.Delete()
Next
If HasSubAsm(oOccs) Then GoTo ReturnStep
End Sub
Private Function HasSubAsm(ByVal oOccs As ComponentOccurrences) As Boolean
For i As Integer = 1 To oOccs.Count
If oOccs(i).DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then Return True
Next i
Return False
End Function
How can i fix it?