Message 1 of 6
Import Pagesetups from .dwg file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I would like a command that imports all pagesetups (?plotsettings?) from an existing drawing to the current one.
I found this code but, TBH, I can't follow it and it throws an exception on the line: cpl.CopyFrom(pl)
Public Sub ClonePlotSettings(FilePath As String) Dim DestDb As Database = Application.DocumentManager.MdiActiveDocument.Database Dim SourceDb As New Database(False, True) Using docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument() Try SourceDb.ReadDwgFile(FilePath, System.IO.FileShare.ReadWrite, False, Nothing) Using currentTransaction As Transaction = CurrentDatabase.TransactionManager.StartTransaction Using sourceTransaction As Transaction = SourceDatabase.TransactionManager.StartTransaction Dim sourcePlotDic As DBDictionary = SourceDatabase.PlotSettingsDictionaryId.GetObject(OpenMode.ForRead) Dim objID As ObjectId For Each item As DBDictionaryEntry In sourcePlotDic objID = sourcePlotDic.GetAt(item.Key) Dim pl As PlotSettings = objID.GetObject(OpenMode.ForRead) Try Dim cpl As New PlotSettings(False) cpl.CopyFrom(pl) cpl.AddToPlotSettingsDictionary(CurrentDatabase) Catch ex As Exception 'MsgBox("Exception in ClonePlotSettings:" + ex.Message) End Try Next currentTransaction.Commit() End Using End Using End Using SourceDb.Dispose() End Sub
Can someone help me out? I've found similar posts but are either unanswered or are copying layouts rather than plot settings.