- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hopefully someone can help me because i'm really stuck on this one. I am trying to write some code to move all the top level folders, to the top of the browser panel in an assembly. (i said top level because there can be sub folders sometimes and i just want the leave them where they are under the top level folder)
I am getting very weird results and nothing seems to work. Can someone help me out please?
First Issue
When trying to check the native object type under the node. Ilogic + vba just throw an error. it doesn't seem to recognise "NativeObject" although it's there in the object browser in VBA. see below for excerpt i think should work but doesn't
If oBN.NativeObject.Type = ObjectTypeEnum.kBrowserFolderObject Then 'Do something End If
To get around this, i added all of the folder names to a list then do a compare on the "BrowserNodeDefinition.Label " which seems to work ok.
Second Issue
I am using the "End of part" node, that seems to always be the last node before the first assembly occurrence but when i try and re-order the browser tree it randomly moves the folders around and crashes if a folder is at the top of the browser. I have tried inserting the new positions before / after the first browser node but nothing seems to work.
Any ideas would be much appreciated.
I am using Inventor 2019 Pro / Windows 10
Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim oBP As BrowserPane = oDoc.BrowserPanes.Item("Model") ' Check there are folders in the browser If oBP.TopNode.BrowserFolders.Count = 0 Then MessageBox.Show("There are no folders in this assembly", "test") Exit Sub End If Dim myList As New List(Of String) For Each oBF As BrowserFolder In oBP.TopNode.BrowserFolders myList.Add(oBF.Name) Next Dim i As Integer = 5 Dim intEnd As Integer = 0 For i = 1 To oBP.TopNode.BrowserNodes.Count If oBP.TopNode.BrowserNodes.Item(i).BrowserNodeDefinition.Label = "End of Features" Then Logger.Info("End Node found") ' Found end node, now save the index number intEnd = i End If Next ' Iterate through top level nodes only (does not go into sub folders) For Each oBN As BrowserNode In oBP.TopNode.BrowserNodes If myList.Contains(oBN.BrowserNodeDefinition.Label) Then oBP.Reorder(oBN, True, oBP.TopNode.BrowserNodes.Item(intEnd+1)) End If Next
Thanks, Matt.
Solved! Go to Solution.