← Inbox

C3DO-0887 · 251205: plot SO PINS layout to PDF (read-only) [C3D-SOPLOT1205] done

Plots layout SO PINS to '251205 - SO PINS layout.pdf' beside the drawing (recipe plot-layout-pdf).

Script file
C3DO-0887.cs
Target
251205 - 157 Scenic Hwy N.dwg · model space
Author
claude
Approved
yes · read-only
Timeout
60s

C# payload

// 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),"251205 - SO PINS layout.pdf");
var ld=(DBDictionary)Tx.GetObject(Db.LayoutDictionaryId,OpenMode.ForRead);
var lo=(Layout)Tx.GetObject(ld.GetAt("SO PINS"),OpenMode.ForRead);
Log("layout "+"SO PINS"+" 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!="SO PINS") lm.CurrentLayout="SO PINS";
 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

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\251205 - 157 Scenic Hwy N, Lawrenceville, GA 30046, USA\251205 - 157 Scenic Hwy N.dwg
Message
Executed C3DO-0887 (0 entities touched).
Entities
—
Duration
1534 ms
Civil 3D
25.0.0.0

Log

layout SO PINS 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\251205 - 157 Scenic Hwy N, Lawrenceville, GA 30046, USA\251205 - SO PINS layout.pdf exists=True bytes=177651 time=11/24/2026 11:35:21 AM

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.