I have create a routine that create's a blank layout, but with the plotsettings of a existing layout.
This is the routine that i have created, it works wel for me and i have posted it here because it is created with the help of this forum and i have read some questions of people who wanted to do a similar thing.
Private Function Create_Layout(ByVal OriginalLayout As String, ByVal NewLayout As String) As Boolean
Try
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim doclock As DocumentLock = doc.LockDocument()
Dim db As Database = doc.Database
Dim trm As DBTransMan = db.TransactionManager
Using tr As Transaction = trm.StartTransaction()
Try
Dim lman As LayoutManager = LayoutManager.Current
Dim lcnt As Integer = lman.LayoutCount
lman.CreateLayout(NewLayout)
Set_LayoutCurrent(NewLayout)
tr.Commit()
Catch ex As Exception
System.Windows.Forms.MessageBox.Show("An error occured in Create_Layout fase 1" & vbCrLf & ex.ToString)
tr.Abort()
tr.Dispose()
doclock.Dispose()
Return False
End Try
End Using
Using tr As Transaction = trm.StartTransaction()
Try
Dim lman As LayoutManager = LayoutManager.Current
Dim LnId As ObjectId = lman.GetLayoutId(NewLayout)
Dim Ln As Layout = CType(tr.GetObject(LnId, OpenMode.ForWrite), Layout)
Dim LoId As ObjectId = lman.GetLayoutId(OriginalLayout)
Dim Lo As Layout = CType(tr.GetObject(LoId, OpenMode.ForRead), Layout)
Dim plotSet As PlotSettings = New PlotSettings(False)
plotSet.CopyFrom(Lo)
Ln.CopyFrom(plotSet)
tr.Commit()
Catch ex As Exception
System.Windows.Forms.MessageBox.Show("An error occured in Create_Layout fase 2" & vbCrLf & ex.ToString)
tr.Abort()
tr.Dispose()
doclock.Dispose()
Return False
End Try
End Using
doclock.Dispose()
Return True
Catch ex As Exception
System.Windows.Forms.MessageBox.Show("An error occured in Create_Layout main" & vbCrLf & ex.ToString)
Return False
End Try
End Function
If this kind of postings are unwanted, please let me know, otherwise i do like comments on my code, it can always be improved.