I am using an exact copy of the sample. (At least I don't I modified it...)
Public Sub AddPlotSettings(ByVal PlotSettingsFile As String, ByVal PlotSettingsName As String)
Dim CurrentDatabase As Database = HostApplicationServices.WorkingDatabase
Dim SourceDatabase As New Database(False, True)
SourceDatabase.ReadDwgFile(PlotSettingsFile, FileOpenMode.OpenForReadAndAllShare, True, "")
Using currentTransaction As Transaction = CurrentDatabase.TransactionManager.StartTransaction
Using sourceTransaction As Transaction = SourceDatabase.TransactionManager.StartTransaction
Dim sourcePlotDic As DBDictionary = CType(SourceDatabase.PlotSettingsDictionaryId.GetObject(OpenMode.ForRead), DBDictionary)
If sourcePlotDic.Contains(PlotSettingsName) Then
Dim objID As ObjectId = sourcePlotDic.GetAt(PlotSettingsName)
Dim pl As PlotSettings = CType(objID.GetObject(OpenMode.ForRead), PlotSettings)
Dim cpl As New PlotSettings(False)
cpl.CopyFrom(pl)
cpl.AddToPlotSettingsDictionary(CurrentDatabase)
Dim bt As BlockTable = CType(CurrentDatabase.BlockTableId.GetObject(OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = CType(bt(BlockTableRecord.PaperSpace).GetObject(OpenMode.ForRead), BlockTableRecord)
Dim lytobjID As ObjectId = btr.LayoutId.GetObject(OpenMode.ForRead).ObjectId
Dim lytps As PlotSettings = CType(lytobjID.GetObject(OpenMode.ForWrite), PlotSettings)
lytps.CopyFrom(cpl)
End If
currentTransaction.Commit()
End Using
End Using
End Sub
See attachments