Assembly: Promote subcomponent in a hidden document

Assembly: Promote subcomponent in a hidden document

mirkomaga
Contributor Contributor
441 Views
4 Replies
Message 1 of 5

Assembly: Promote subcomponent in a hidden document

mirkomaga
Contributor
Contributor

Hello,

I have tried to promote the subcomponent of an assembly component.
It works if I open the visible document, but if it is hidden it doesn't.
Is there a reason?

 

 

mirkomaga_1-1634632244732.png

 

0 Likes
442 Views
4 Replies
Replies (4)
Message 2 of 5

Stakin
Collaborator
Collaborator

before end sub

add 

oDoc.Update

oDoc.Close

 

 

 

See agian

 

0 Likes
Message 3 of 5

mirkomaga
Contributor
Contributor

mhh, add(?)

Error is before.

 

mirkomaga_0-1634636669300.pngmirkomaga_1-1634636685127.png

 

0 Likes
Message 4 of 5

Stakin
Collaborator
Collaborator

post your code in txt

 

0 Likes
Message 5 of 5

mirkomaga
Contributor
Contributor

Yes sorry

 

 

Sub test()
       
        Dim s As String
        s = "pathiam"

        ' Get the active assembly document
        Dim oDoc As AssemblyDocument
        Set oDoc = ThisApplication.Documents.Open(s, False)
    
        Dim oDef As AssemblyComponentDefinition
        Set oDef = oDoc.ComponentDefinition
    
        ' Get the top level occurrence of an assembly
        Dim oSubAssyOcc As ComponentOccurrence
        Set oSubAssyOcc = oDef.Occurrences.Item(1)
    
        ' Get the 2nd level occurrence under the assembly occurrence
        Dim oSubOcc As ComponentOccurrenceProxy
        Set oSubOcc = oDef.Occurrences.Item(1).SubOccurrences.Item(1)
    
        Dim oPane As BrowserPane
        Set oPane = oDoc.BrowserPanes.Item("Model")
    
        ' Get the browser nodes corresponding to the two occurrences
        Dim oTargetNode As BrowserNode
        Set oTargetNode = oPane.GetBrowserNodeFromObject(oSubAssyOcc)
    
        Dim oSourceNode As BrowserNode
        Set oSourceNode = oPane.GetBrowserNodeFromObject(oSubOcc)
    
        ' Reorder the nodes to promote the sub-occurrence to the top level
        Call oPane.Reorder(oTargetNode, True, oSourceNode)

End Sub
0 Likes