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: 

Sort drawings views in Sheet within browser

0 REPLIES 0
Reply
Message 1 of 1
edgar3M4N8
83 Views, 0 Replies

Sort drawings views in Sheet within browser

I am trying to sort drawings views in a Sheet within the browser by size, but I cant make it work. Right now the rule is doing nothing. Could you be able to help?
I need to have the only organized on the browser as with that I can run another rule that will organize and space all the views within the drawing space


Sub main() Dim drawingDoc As DrawingDocument = ThisDoc.Document Dim sheet As Sheet = drawingDoc.Sheets.Item(1) ' Assuming you're working with the first sheet Dim viewsList As New List(Of DrawingView) ' Collect all drawing views on the sheet For Each view As DrawingView In sheet.DrawingViews viewsList.Add(View) Next ' Sort the views based on their size (width * height) viewsList.Sort(AddressOf CompareViewsBySize) ' Reorder the views in the browser Dim browserPane As BrowserPane = drawingDoc.BrowserPanes.Item("Model") For i As Integer = 0 To viewsList.Count - 1 Dim viewNode As BrowserNode = browserPane.GetBrowserNodeFromObject(viewsList(i)) Dim bottomNode As BrowserNode = browserPane.TopNode.BrowserNodes.Item(browserPane.TopNode.BrowserNodes.Count) browserPane.Reorder(bottomNode, False, viewNode) Next End Sub Private Function CompareViewsBySize(view1 As DrawingView, view2 As DrawingView) As Integer Dim size1 As Double = view1.Width * view1.Height Dim size2 As Double = view2.Width * view2.Height Return size1.CompareTo(size2) End Function

 

0 REPLIES 0

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report