Select Multiple Browser Nodes in Drawing

Select Multiple Browser Nodes in Drawing

johnster100
Collaborator Collaborator
1,305 Views
3 Replies
Message 1 of 4

Select Multiple Browser Nodes in Drawing

johnster100
Collaborator
Collaborator

Hi,

I have code which will find a browser node of a model part in the drawing environment. I then use the following code to turn on hidden lines for the selected node:

 

        'Dim oNode As BrowserNode
        oNode.Expanded = True
        oNode.DoPreSelect()
        oNode.DoSelect()

        Dim oControlDef As ControlDefinition
        oControlDef = oCommandMgr.ControlDefinitions.Item("DrawingBodyHiddenLinesCtxCmd")

        oControlDef.Execute2(True)

 

This works fine but I have to select one node at time then run the command as '.DoSelect' doesn't appear to allow multiple nodes to be selected.

 

This is really slowing down my drawing update as I have to show hidden lines for about 30 components (across multiple views).

 

Is there a way to select multiple nodes at once?

(then I could just run the hidden lines command once)

 

I tried using SelectSet but could not get this to work 😞

 

Any help is greatly appreciated,

thanks,

John

1,306 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@johnster100,

 

Hoping that below iLogic code would help to select multiple nodes. Before running this code, make sure that selection is made browser node.

 

Sub Main()
    Dim oDoc As DrawingDocument
    oDoc = ThisApplication.ActiveDocument
    
    Dim oTopBrowserNode As BrowserNode
    oTopBrowserNode = oDoc.BrowserPanes.ActivePane.TopNode
    
    Dim objColl As ObjectCollection
    objColl = ThisApplication.TransientObjects.CreateObjectCollection
    
    Call Get_SelectedNodes(oTopBrowserNode, objColl)
    
    Dim oNode As BrowserNode
    For Each oNode In objColl
		  
        oNode.Expanded = True
        oNode.DoPreSelect()
        oNode.DoSelect()

        Dim oControlDef As ControlDefinition
        oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingBodyHiddenLinesCtxCmd")

        oControlDef.Execute2(True)
    Next
    
End Sub

Sub Get_SelectedNodes(oTopBrowserNode As BrowserNode, ByRef objColl As ObjectCollection)
    Dim oNode As BrowserNode
    For Each oNode In oTopBrowserNode.BrowserNodes
        If oNode.Selected = True Then
            Call objColl.Add(oNode)
        ElseIf oNode.BrowserNodes.Count > 0 Then
            Call Get_SelectedNodes(oNode, objColl)
        End If
    Next
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 4

johnster100
Collaborator
Collaborator

Hi Chandra,

thanks for the reply.

 

Unfortunately this does not help as I'm trying to only run the 'show hidden lines' command once. Using the for loop with the collection does not achieve this.

 

I'm try to run the command only once as the view seems to regenerate each time it is run, so it is very slow to run it multiple times.

 

thanks again,

John

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@johnster100,

 

As Browser node is entity object, browser node collection can not be added to SelectMultple(EntityColleciton) method. For more details, refer below help documentation on Inventor 2018 API.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-77E546E6-0AA9-4907-B2B4-6946AB500C66

 

Below iLogic code does the same behavior by selecting individual browser node.

 

Sub Main()
    Dim oDoc As DrawingDocument
    oDoc = ThisApplication.ActiveDocument
    
    Dim oTopBrowserNode As BrowserNode
    oTopBrowserNode = oDoc.BrowserPanes.ActivePane.TopNode
    
    Dim objColl As ObjectCollection
    objColl = ThisApplication.TransientObjects.CreateObjectCollection
    
    Call Get_SelectedNodes(oTopBrowserNode, objColl)
    
    Dim oNode As BrowserNode
    For Each oNode In objColl
		
	oNode.Expanded = True   
        
        oNode.DoPreSelect() 
		
        Dim oControlDef As ControlDefinition
        oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingBodyHiddenLinesCtxCmd")

        oControlDef.Execute2(False)
		
	Call ThisApplication.UserInterfaceManager.DoEvents() 

    Next
    
End Sub

Sub Get_SelectedNodes(oTopBrowserNode As BrowserNode, ByRef objColl As ObjectCollection)
    Dim oNode As BrowserNode
    For Each oNode In oTopBrowserNode.BrowserNodes
        If oNode.Selected = True Then
            Call objColl.Add(oNode)
        ElseIf oNode.BrowserNodes.Count > 0 Then
            Call Get_SelectedNodes(oNode, objColl)
        End If
    Next
End Sub

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Like".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes