Below code shows the procedure to copy the plot setting from one drawing to the current drawing file.
[CommandMethod("CopyPlotSetting")]
static public void CopyPlotSetting()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database _db = doc.Database;
using (Database _srDb = new Database(false, true))
{
_srDb.ReadDwgFile("c:\temp\testPlot.dwg",
System.IO.FileShare.Read,
true, null);
using (Transaction _templateTr =
_srDb.TransactionManager.StartTransaction())
{
using (Transaction _tr =
_db.TransactionManager.StartTransaction())
{
DBDictionary dbDict = _templateTr.GetObject(
_srDb.PlotSettingsDictionaryId,
OpenMode.ForRead) as DBDictionary;
if (dbDict != null)
{
ObjectId settingsId = ObjectId.Null;
settingsId = dbDict.GetAt("TestPlotSetting");
PlotSettings settings = null;
settings =
_templateTr.GetObject(settingsId,
OpenMode.ForRead) as PlotSettings;
PlotSettings newSettings =
new PlotSettings(true);
newSettings.CopyFrom(settings);
newSettings.AddToPlotSettingsDictionary(_db);
_tr.AddNewlyCreatedDBObject(newSettings, true);
}
_tr.Commit();
}
_templateTr.Commit();
}
}
}

Leave a Reply