Quantcast
Viewing all articles
Browse latest Browse all 14319

Cloning a Layout Using the Same Taborder

Hi, I have a program that lets the user create a new page, by cloning a selected page and placing it at the desired layout order (taborder).  For example, the user could copy layout 4 as layout 3 and then there are options for changing the layers that are visible.

The problem I'm running into is when a user enters new page = 3, by copying the current layout 3.  What I want is to have the new layout placed at taborder 3, and the rest moved to the right.

It gives me an error, though, saying I'm using the same taborder.

' This will copy the selected layout and call it the new page.
    Public Sub addPage(ByVal pageNumber As Integer, ByVal pageToCopy As Integer)
        Dim myDWG As ApplicationServices.Document
        Dim myDB As DatabaseServices.Database
        Dim myTransMan As DatabaseServices.TransactionManager
        Dim myTrans As DatabaseServices.Transaction

        myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
        myDB = myDWG.Database
        myTransMan = myDWG.TransactionManager
        myTrans = myTransMan.StartTransaction

        Dim myBT As DatabaseServices.BlockTable
        Dim myBTR As DatabaseServices.BlockTableRecord
        Dim myBTRE As DatabaseServices.SymbolTableEnumerator
        Dim myLM As DatabaseServices.LayoutManager
        Dim myLayout As DatabaseServices.Layout
        Dim layoutToCopy As String

        myBT = myDB.BlockTableId.GetObject(DatabaseServices.OpenMode.ForWrite)
        myBTRE = myBT.GetEnumerator
        myLM = DatabaseServices.LayoutManager.Current

        ' Copies the selected layout to the new layout
        While myBTRE.MoveNext
            myBTR = myBTRE.Current.GetObject(DatabaseServices.OpenMode.ForRead)
            If myBTR.IsLayout Then
                myLayout = myBTR.LayoutId.GetObject(DatabaseServices.OpenMode.ForRead)
                ' If the layout is the selected layout to copy
                If myLayout.TabOrder = pageToCopy Then
                    layoutToCopy = (myLayout.LayoutName)
                    ' Copys the selected layout and puts it in the desired layout location
                    myLM.CloneLayout(layoutToCopy, "newpage", pageNumber)
                End If
            End If
        End While
        myTrans.Commit()
        myDWG.Editor.Regen()
        myTrans.Dispose()
    End Sub

 I thought, maybe I could put the new layout at the end, and then just change its taborder, but all that did was overwrite the current layout 3 with the new layout.

 

Any help would be greatly appreciated.

Mark

Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 14319

Trending Articles