Hi,
Did anyone try to demote a frame member through API?
I tried with command manager:
ThisApplication.SilentOperation = True
Dim oCM As CommandManager
Set oCM = ThisApplication.CommandManager
' Prepopulate the file name of new component in
' the 'Create Component' dialog
oCM.PostPrivateEvent kFileNameEvent, "C:\temp\test\demoted.iam"
Dim oControlDef As ControlDefinition
Set oControlDef = oCM.ControlDefinitions("AssemblyDemoteCmd")
' Execute the demote command
oControlDef.Execute
ThisApplication.SilentOperation = False
I also tried with this example:
Public Sub Demote()
' Get the active assembly document
Dim oDoc As AssemblyDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition
Set oDef = oDoc.ComponentDefinition
' Get the occurrence to be demoted
Dim oOcc As ComponentOccurrence
Set oOcc = oDef.Occurrences.Item(1)
' Create a new sub-assembly to demote the occurrence into
Dim oNewSubAssy As AssemblyDocument
Set oNewSubAssy = ThisApplication.Documents.Add(kAssemblyDocumentObject, , False)
Dim oMat As Matrix
Set oMat = ThisApplication.TransientGeometry.CreateMatrix
' Create an instance of the new sub-assembly
Dim oSubAssyOcc As ComponentOccurrence
Set oSubAssyOcc = oDef.Occurrences.AddByComponentDefinition(oNewSubAssy.ComponentDefinition, oMat)
' Get the model browser
Dim oPane As BrowserPane
Set oPane = oDoc.BrowserPanes.Item("Model")
' Get the browser node that corresponds to the new sub-assembly occurrence
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 Long
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
' Get the browser node that corresponds to the occurrence to be demoted
Dim oSourceNode As BrowserNode
Set oSourceNode = oPane.GetBrowserNodeFromObject(oOcc)
' Demote the occurrence
Call oPane.Reorder(oTargetNode, False, oSourceNode)
End Sub
But no luck, it won't demote.
Same codes work in a standard assembly.
Any advice?
Thanks
Autodesk Inventor 2015 Certified Professional