Jump to content

Adding layouts to sheet set in proper order


EYNLLIB

Recommended Posts

I am creating a program that looks at all the current drawing layouts, and then imports them to a new sheet set. I have it working, but the problem is the sheets are added in numerical order from bottom to top, rather than top to bottom. 

 

Anyone have any guidance on controlling the order while importing layouts? Or maybe a better route is to have the sheets re-ordered programmatically once they're imported?

 

Here's the function in question

 

 

Thanks

 

 

 

' Import a sheet into a sheet set
Private Function ImportASheet(ByVal component As IAcSmComponent, _
                              ByVal title As String, _
                              ByVal description As String, _
                              ByVal number As String, _
                              ByVal fileName As String, _
                              ByVal layout As String) As AcSmSheet
    On Error GoTo ErrorHandler

    Dim sheet As AcSmSheet
    Dim layoutReference As AcSmAcDbLayoutReference  
    Set layoutReference = New AcSmAcDbLayoutReference  
    layoutReference.InitNew component    
    layoutReference.SetFileName fileName    
    layoutReference.SetName layout    
    
    If TypeOf component Is AcSmSheetSet Then        
        Dim sheetSet As AcSmSheetSet
        Set sheetSet = component        
        Set sheet = sheetSet.ImportSheet(layoutReference)
        If sheet Is Nothing Then            
            Err.Raise vbObjectError + 1001, , "Failed to import sheet into sheet set"
        End If        
        sheetSet.InsertComponent sheet, Nothing
    Else        
        Err.Raise vbObjectError + 1002, , "Unexpected component type"
    End If
    
    sheet.SetDesc description
    sheet.SetTitle title
    If number <> "" Then
        sheet.SetNumber number
    End If    

    Set ImportASheet = sheet
    Exit Function

 

Link to comment
Share on other sites

Posted (edited)

Okay after checking around the developer help files online, I found out the solution is incredibly easy and simple

 

rather than InsertComponent, I use InsertComponentAfter

Edited by EYNLLIB
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...