.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

create new layout

1 REPLY 1
Reply
Message 1 of 2
Anonymous
688 Views, 1 Reply

create new layout

A want to create a new layout. This all works fine. I now want to add some code to see if the option in Autocad "create new viewort in new layout" is checked. If yes, uncheck it before running my code. How can I to this ?

 

 

 Public Function maaklayout(ByVal naamlayout As String) As DatabaseServices.ObjectId

        Dim myDWG As ApplicationServices.Document
        Dim myDB As DatabaseServices.Database
        Dim myTransMan As DatabaseServices.TransactionManager
        Dim myTrans As DatabaseServices.Transaction
        Dim newlayout As Boolean
        myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
        myDB = myDWG.Database
        newlayout = True
        Using tr As Transaction = myDB.TransactionManager.StartTransaction()
            Dim layDict As DBDictionary = DirectCast(tr.GetObject(myDB.LayoutDictionaryId, OpenMode.ForRead), DBDictionary)
            For Each entry As DBDictionaryEntry In layDict
                Dim name As String = entry.Key
                If name = naamlayout Then
                    newlayout = False
                End If
            Next
            tr.Commit()
        End Using

        If newlayout Then
            myTransMan = myDWG.TransactionManager
            myTrans = myTransMan.StartTransaction
            Dim myLayout As New DatabaseServices.Layout
            Dim myLM As DatabaseServices.LayoutManager
            myLM = DatabaseServices.LayoutManager.Current
            myLayout = myLM.CreateLayout(naamlayout).GetObject(DatabaseServices.OpenMode.ForWrite)
            myTrans.Commit()
            myTrans.Dispose()
            myTransMan.Dispose()
        End If
    End Function

 

 

 

1 REPLY 1
Message 2 of 2
Paulio
in reply to: Anonymous

You'll be wanting the LAYOUTCREATEVIEWPORT system variable. Smiley Happy

 

Get with Application.GetSystemVariable("LAYOUTCREATEVIEWPORT")

 

and Set with Application.SetSystemVariable("LAYOUTCREATEVIEWPORT",0). 0 = Off (i.e. don't create a viewport when a new layout is created)

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost