08-29-2023
02:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
08-29-2023
02:03 AM
Sorry, I made one small mistake. Try this code:
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
Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.