// Get the PlotInfo from the layout
PlotInfo acPlInfo = new PlotInfo();
acPlInfo.Layout = newLayout.ObjectId;
// Get a copy of the PlotSettings from the layout
PlotSettings acPlSet = new PlotSettings(newLayout.ModelType);
acPlSet.CopyFrom(newLayout);
// Update the PlotConfigurationName property of the PlotSettings object
PlotSettingsValidator acPlSetVdr = PlotSettingsValidator.Current;
acPlSetVdr.SetPlotType(acPlSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Layout);
acPlSetVdr.SetUseStandardScale(acPlSet, true);
acPlSetVdr.SetStdScaleType(acPlSet, StdScaleType.StdScale1To1);
acPlSetVdr.SetPlotConfigurationName(acPlSet, "DWG To PDF.pc3",
"UserDefinedMetric (594.00 x 841.00мм)_1");
// Update the layout
newLayout.CopyFrom(acPlSet);
acPlInfo.OverrideSettings = acPlSet;
//ТЕПЕРЬ ПЫТАЮСЬ ЭТОТ ЛИСТ СРАЗУ РАСПЕЧАТАТЬ
String OutPath = dxf.FullName.Replace(dxf.Extension, ".pdf");
Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("BACKGROUNDPLOT", 0);
if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
{
PlotEngine pe = PlotFactory.CreatePublishEngine();
using (pe)
{
PlotProgressDialog ppd = new PlotProgressDialog(false, 1, true);
using (ppd)
{
// Setting up the PlotProgress dialog
ppd.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Custom Plot Progress");
ppd.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job");
ppd.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet");
ppd.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress");
ppd.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress");
ppd.LowerPlotProgressRange = 0;
ppd.UpperPlotProgressRange = 100;
ppd.PlotProgressPos = 0;
ppd.OnBeginPlot();
ppd.IsVisible = true;
pe.BeginPlot(ppd, null);
// Starting new page
ppd.StatusMsgString = "Plotting layout";
ppd.OnBeginSheet();
ppd.LowerSheetProgressRange = 0;
ppd.UpperSheetProgressRange = 100;
ppd.SheetProgressPos = 0;
PlotInfoValidator piv = new PlotInfoValidator();
piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
PlotPageInfo ppi = new PlotPageInfo();
(1) piv.Validate(acPlInfo);
(2) pe.BeginDocument(acPlInfo, dxf.Name, null, 1, true, OutPath); // Create document for the first page
// Finish the document and finish the plot
pe.EndDocument(null);
ppd.PlotProgressPos = 100;
ppd.OnEndPlot();
pe.EndPlot(null);
}
}
}