Community
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
You'll be wanting the LAYOUTCREATEVIEWPORT system variable.
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)