← Inbox

C3D-0681 · 261009 plot 11X17 DEMO to PDF (read-only) [C3D-PLOT1009] done

Plots 11X17 DEMO to PDF beside the drawing (plot-layout-pdf recipe).

Script file
C3D-0681.cs
Target
261009 - 510 Covington Cove.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

string pdf=System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Db.Filename),"261009 - 510 Covington Cove - 11X17 DEMO.pdf");
var ld=(DBDictionary)Tx.GetObject(Db.LayoutDictionaryId,OpenMode.ForRead);
var lo=(Layout)Tx.GetObject(ld.GetAt("11X17 DEMO"),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 DEMO") lm.CurrentLayout="11X17 DEMO";
 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\261009 - 510 Covington Cove, Byron, GA 31008, USA\261009 - 510 Covington Cove.dwg
Message
Executed C3D-0681 (0 entities touched).
Entities
—
Duration
1122 ms
Civil 3D
25.0.0.0

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\261009 - 510 Covington Cove, Byron, GA 31008, USA\261009 - 510 Covington Cove - 11X17 DEMO.pdf exists=True bytes=347385 time=11/3/2026 1:08:02 AM

Notes

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

No notes yet.