iLogic Macro: Sort Drawing Sheets


We all need to have some order in our documents.

So here is a small iLogic macro that I created to sort drawing sheets by name:

Sub Main()

    Dim drawingDoc As DrawingDocument = ThisDoc.Document
    Dim sheet As Sheet = Nothing
    Dim sheetsList As New List(Of Sheet)
    Dim browserPane As BrowserPane = drawingDoc.BrowserPanes.Item("Model")
    For Each sheet In drawingDoc.Sheets

    sheetsList.Sort(AddressOf Comparer)

    For Each sheet In sheetsList
        Dim sheetNode As BrowserNode = browserPane.GetBrowserNodeFromObject(sheet)
        Dim bottomNode As BrowserNode = browserPane.TopNode.BrowserNodes.Item(browserPane.TopNode.BrowserNodes.Count)
        browserPane.Reorder(bottomNode, False, sheetNode)

End Sub

Private Function Comparer(x As Sheet, y As Sheet) As Integer
    Return String.Compare(x.Name, y.Name)
End Function

You may also like...