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: 

Using API to Sort Drawing Sheets

1 REPLY 1
SOLVED
Reply
Message 1 of 2
inulobo
643 Views, 1 Reply

Using API to Sort Drawing Sheets

inulobo
Advocate
Advocate

I am stuck. I am not sure where I am going wrong. I am trying to sort the drawing sheets by name alphanumerically. Looking for some input. I am trying to do it with a collection.

 

 

 

Sub Sort_DrawingSheets()
    Dim drawingDoc As DrawingDocument
    'Set drawingDoc = ThisDoc.Document
    Set drawingDoc = ThisApplication.ActiveDocument
    
    Dim sheet As sheet
    Dim oSheets As Sheets
    Set oSheets = drawingDoc.Sheets
    
    Dim sheetsList As New Collection
    Set sheetsList = New Collection
    
    Dim vTemp As Variant
    
    Dim browserPane As browserPane
    Set browserPane = drawingDoc.BrowserPanes.item("Model")
    

    For Each sheet In oSheets
        sheetsList.Add (sheet.Name)
    Next

    For i = 1 To sheetsList.Count - 1
        For j = i + 1 To sheetsList.Count
            If sheetsList.item(i) > sheetsList.item(j) Then
                vTemp = sheetsList.item(j)
                sheetsList.Remove j
                sheetsList.Add vTemp, vTemp, i
            End If
        Next j
    Next i
        
    For Each sheet In sheetsList
        Dim sheetNode As BrowserNode
        Set sheetNode = browserPane.GetBrowserNodeFromObject(sheet)
        
        Dim bottomNode As BrowserNode
        Set bottomNode = browserPane.TopNode.BrowserNodes.item(browserPane.TopNode.BrowserNodes.Count)
        
        Call browserPane.Reorder(bottomNode, False, sheetNode)
    Next
    
End Sub

 

 

0 Likes

Using API to Sort Drawing Sheets

I am stuck. I am not sure where I am going wrong. I am trying to sort the drawing sheets by name alphanumerically. Looking for some input. I am trying to do it with a collection.

 

 

 

Sub Sort_DrawingSheets()
    Dim drawingDoc As DrawingDocument
    'Set drawingDoc = ThisDoc.Document
    Set drawingDoc = ThisApplication.ActiveDocument
    
    Dim sheet As sheet
    Dim oSheets As Sheets
    Set oSheets = drawingDoc.Sheets
    
    Dim sheetsList As New Collection
    Set sheetsList = New Collection
    
    Dim vTemp As Variant
    
    Dim browserPane As browserPane
    Set browserPane = drawingDoc.BrowserPanes.item("Model")
    

    For Each sheet In oSheets
        sheetsList.Add (sheet.Name)
    Next

    For i = 1 To sheetsList.Count - 1
        For j = i + 1 To sheetsList.Count
            If sheetsList.item(i) > sheetsList.item(j) Then
                vTemp = sheetsList.item(j)
                sheetsList.Remove j
                sheetsList.Add vTemp, vTemp, i
            End If
        Next j
    Next i
        
    For Each sheet In sheetsList
        Dim sheetNode As BrowserNode
        Set sheetNode = browserPane.GetBrowserNodeFromObject(sheet)
        
        Dim bottomNode As BrowserNode
        Set bottomNode = browserPane.TopNode.BrowserNodes.item(browserPane.TopNode.BrowserNodes.Count)
        
        Call browserPane.Reorder(bottomNode, False, sheetNode)
    Next
    
End Sub

 

 

Tags (2)
Labels (2)
1 REPLY 1
Message 2 of 2
inulobo
in reply to: inulobo

inulobo
Advocate
Advocate
Accepted solution

Nevermind figured it out. Cannot use a regular collection needed object collection. 

0 Likes

Nevermind figured it out. Cannot use a regular collection needed object collection. 

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

Post to forums  

Autodesk Design & Make Report