C3DO-0854 · 261103: plot 11X17 to PDF (read-only) [C3D-PLOT1103] done
Plots the 11X17 layout to 261103-0WaltStephensRd-11X17-R1.pdf beside the drawing (DWG To PDF, layout media + plot style).
C# payload
string F(double v)=>v.ToString("0.###");
ObjectId H(string h)=>Db.GetObjectId(false,new Handle(Convert.ToInt64(h,16)),0);
ObjectId Lyr(string name,short c){ var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead); if(lt.Has(name)) return lt[name]; lt.UpgradeOpen(); var r=new LayerTableRecord{Name=name,Color=Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci,c)}; var id=lt.Add(r); Tx.AddNewlyCreatedDBObject(r,true); Log("layer created "+name); return id; }
ObjectId Put(BlockTableRecord btr, Autodesk.AutoCAD.DatabaseServices.Entity e, string layer){ e.SetDatabaseDefaults(Db); e.Layer=layer; var id=btr.AppendEntity(e); Tx.AddNewlyCreatedDBObject(e,true); return id; }
var LM=LayoutManager.Current;
BlockTableRecord PS(string name){ var l=(Layout)Tx.GetObject(LM.GetLayoutId(name),OpenMode.ForRead); return (BlockTableRecord)Tx.GetObject(l.BlockTableRecordId,OpenMode.ForWrite); }
var BT=(BlockTable)Tx.GetObject(Db.BlockTableId,OpenMode.ForRead);
var MS=(BlockTableRecord)Tx.GetObject(BT[BlockTableRecord.ModelSpace],OpenMode.ForWrite);
bool HasText(BlockTableRecord btr,string contains){ foreach(ObjectId id in btr){ var o=Tx.GetObject(id,OpenMode.ForRead); if(o is MText m && m.Contents.Contains(contains)) return true; if(o is DBText t && t.TextString.Contains(contains)) return true; } return false; }
// PLOT ONE LAYOUT TO PDF beside the drawing (read-only: no entities change).
// Proven 261103 on 261009 (C3D-0664..). Uses the layout's own media + plot style, DWG To PDF.pc3,
// BACKGROUNDPLOT=0 for the duration, and restores the current layout tab afterwards.
string pdf=System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Db.Filename),"261103-0WaltStephensRd-11X17-R1.pdf");
var ld=(DBDictionary)Tx.GetObject(Db.LayoutDictionaryId,OpenMode.ForRead);
var lo=(Layout)Tx.GetObject(ld.GetAt("11X17"),OpenMode.ForRead);
Log("layout "+"11X17"+" device='"+lo.PlotConfigurationName+"' media='"+lo.CanonicalMediaName+"' style='"+lo.CurrentStyleSheet+"'");
var lm=Autodesk.AutoCAD.DatabaseServices.LayoutManager.Current; string prev=lm.CurrentLayout;
object bg=Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("BACKGROUNDPLOT");
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT",(short)0);
try{
if(prev!="11X17") lm.CurrentLayout="11X17";
var ps=new PlotSettings(false); ps.CopyFrom(lo);
var psv=PlotSettingsValidator.Current;
psv.SetPlotConfigurationName(ps,"DWG To PDF.pc3",lo.CanonicalMediaName);
var pi=new Autodesk.AutoCAD.PlottingServices.PlotInfo(); pi.Layout=lo.ObjectId; pi.OverrideSettings=ps;
var piv=new Autodesk.AutoCAD.PlottingServices.PlotInfoValidator(); piv.MediaMatchingPolicy=Autodesk.AutoCAD.PlottingServices.MatchingPolicy.MatchEnabled; piv.Validate(pi);
if(Autodesk.AutoCAD.PlottingServices.PlotFactory.ProcessPlotState!=Autodesk.AutoCAD.PlottingServices.ProcessPlotState.NotPlotting){ Log("BUSY - another plot is running"); }
else using(var pe=Autodesk.AutoCAD.PlottingServices.PlotFactory.CreatePublishEngine()){
pe.BeginPlot(null,null);
pe.BeginDocument(pi,Db.Filename,null,1,true,pdf);
var ppi=new Autodesk.AutoCAD.PlottingServices.PlotPageInfo();
pe.BeginPage(ppi,pi,true,null); pe.BeginGenerateGraphics(null); pe.EndGenerateGraphics(null); pe.EndPage(null);
pe.EndDocument(null); pe.EndPlot(null);
}
} finally {
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT",bg);
if(lm.CurrentLayout!=prev) lm.CurrentLayout=prev;
}
var fi=new System.IO.FileInfo(pdf); Log("pdf="+pdf+" exists="+fi.Exists+(fi.Exists?" bytes="+fi.Length+" time="+fi.LastWriteTime:""));
Result
Log
layout 11X17 device='AutoCAD PDF (General Documentation).pc3' media='ANSI_full_bleed_B_(11.00_x_17.00_Inches)' style='monochrome.ctb' pdf=C:\Users\sanja\OneDrive\_SurveyDisco\261103 - Ahmed J Ahmed Real Estate Company LLC\261103-0WaltStephensRd-11X17-R1.pdf exists=True bytes=348927 time=11/23/2026 2:11:18 AM
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.