INVENTOR 2020 CRASHES ON REORDERING NODES

INVENTOR 2020 CRASHES ON REORDERING NODES

Olsndot
Enthusiast Enthusiast
400 Views
0 Replies
Message 1 of 1

INVENTOR 2020 CRASHES ON REORDERING NODES

Olsndot
Enthusiast
Enthusiast

Hi All,

 

So I have  VBA code to demote the occurrences into sub assembly.

When I run the code, INVENTOR crashes.

Any ideas on this issue? 

 

Sub Demote_into_Assembly()

    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
   
    Dim oAsmCompDef As AssemblyComponentDefinition
    Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
    
    Dim oSelset As SelectSet
    Set oSelset = oAsmDoc.SelectSet
    If oSelset.Count = 0 Then Exit Sub
    
    Dim selectAsm As ComponentOccurrence
    Set selectAsm = ThisApplication.CommandManager.Pick _
    (SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select the Assembly to demote the occurrence into [ESC:Cancel]")
    
    If selectAsm Is Nothing Then Exit Sub
    
    Dim oPane As BrowserPane
    Set oPane = oAsmDoc.BrowserPanes.Item("Model")
    
    Dim oSubAssyNode As BrowserNode
    Set oSubAssyNode = oPane.GetBrowserNodeFromObject(selectAsm)
    
    Dim oTargetNode As BrowserNode
    Dim l As Long
    
    For l = oSubAssyNode.BrowserNodes.Count To 1 Step -1
   
        If Not oSubAssyNode.BrowserNodes.Item(l).NativeObject Is Nothing Then
        
            If oSubAssyNode.BrowserNodes.Item(l).NativeObject.Type = kComponentOccurrenceProxyObject Then

                Set oTargetNode = oSubAssyNode.BrowserNodes.Item(l)
                Exit For
            
            End If
        End If
    Next
    
    Dim oOcc As ComponentOccurrence
    Dim oSourceNode As BrowserNode
            
    For Each oOcc In oSelset

            Set oSourceNode = oPane.GetBrowserNodeFromObject(oOcc)
            
        '↓↓↓↓↓↓Crashes on this line↓↓↓↓↓↓
            Call oPane.Reorder(oTargetNode, False, oSourceNode)
       
    Next
    
    oPane.Update

End Sub

 

0 Likes
401 Views
0 Replies
Replies (0)