Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Method 'Reorder' for Demoting Pattern to New Sub-Assembly Fails

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
jacofiero
509 Views, 2 Replies

Method 'Reorder' for Demoting Pattern to New Sub-Assembly Fails

I'm trying to automate the creation of a new subassembly and demote a circular occurrence pattern to it.  I can do it, manually, without incident but the VBA macro kicks out an error.  I set SilentOperation = True, but VBA still kicks out the error and my pattern doesn't get demoted.

 

Here's the code.  I'd appreciate any help.

 

Public Function TESTDemoteDeck()
    Call InitializeMainObjects
    Dim oNewSubAssy As AssemblyDocument
    Set oNewSubAssy = oApp.Documents.Add(kAssemblyDocumentObject, , False)
    Dim oMat As Matrix
    Set oMat = ThisApplication.TransientGeometry.CreateMatrix
    Dim oSubAssyOcc As ComponentOccurrence
    Set oSubAssyOcc = oAsmCompDef.Occurrences.AddByComponentDefinition(oNewSubAssy.ComponentDefinition, oMat)
    Dim oPane As BrowserPane
    Set oPane = oDoc.BrowserPanes.Item("Model")
    Dim oSubAssyNode As BrowserNode
    Set oSubAssyNode = oPane.GetBrowserNodeFromObject(oSubAssyOcc)

    ' Get the last visible child node under the sub-assembly occurrence
    Dim oTargetNode As BrowserNode
    Dim i As Integer, j As Integer
    For i = oSubAssyNode.BrowserNodes.Count To 1 Step -1
        If oSubAssyNode.BrowserNodes.Item(i).Visible Then
            Set oTargetNode = oSubAssyNode.BrowserNodes.Item(i)
            Exit For
        End If
    Next

    Dim oSourceNode As BrowserNode
    Set oPattern = oAsmCompDef.OccurrencePatterns.Item("PatternName")
    Set oSourceNode = oPane.GetBrowserNodeFromObject(oPattern)
    oApp.SilentOperation = True
    On Error GoTo CheckError
    '##ERROR FROM THE LINE BELOW THIS
    Call oPane.Reorder(oTargetNode, False, oSourceNode)
    oApp.SilentOperation = False
    
CheckError:
    Debug.Print "!!!!Run-time Error!!!!"
    Debug.Print "    Err.Number = " & Err.Number
    Debug.Print "    Err.Descri = " & Err.Description
Resume Next

End Function

 Most of it is taken directly from the code example in the API Help reference

 

 

Oh, here's the error.  I believe it's just a generic automation runtime error.

 

Err.Number = -2147467259
Err.Descri = Method 'Reorder' of object 'BrowserPaneObject' failed

2 REPLIES 2
Message 2 of 3
MjDeck
in reply to: jacofiero

Although you can use BrowserPane.Reorder to demote a component into a subassembly, it doesn't work for a component pattern. We should be able to make it work in a future version.


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 3
jacofiero
in reply to: MjDeck

Fair enough. Thanks for the reply.

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

Post to forums  

Autodesk Design & Make Report