Sort drawings views in Sheet within browser

Sort drawings views in Sheet within browser

edgar3M4N8
Contributor Contributor
161 Views
0 Replies
Message 1 of 1

Sort drawings views in Sheet within browser

edgar3M4N8
Contributor
Contributor
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 Likes
162 Views
0 Replies
Replies (0)