static void ExecutePlotSequence(Document doc, PlotConfiguration config, bool withWindow)
{
using (var tr = doc.Database.TransactionManager.StartOpenCloseTransaction())
{
var blkTableRecord = (BlockTableRecord)tr.GetObject(doc.Database.CurrentSpaceId, OpenMode.ForRead);
var layout = (Layout)tr.GetObject(blkTableRecord.LayoutId, OpenMode.ForRead);
var plotInfo
= new PlotInfo
(); plotInfo.Layout = blkTableRecord.LayoutId;
var plotSettings
= new PlotSettings
(layout
.ModelType); plotSettings.CopyFrom(layout);
var plotSettingsValidator = PlotSettingsValidator.Current;
if (withWindow)
{
var window = getwindow(doc);
if (window == null)
return;
plotSettingsValidator.SetPlotWindowArea(plotSettings, getwindow(doc).Value);
plotSettingsValidator.SetPlotType(plotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Window);
}
else
plotSettingsValidator.SetPlotType(plotSettings, Autodesk.AutoCAD.DatabaseServices.PlotType.Limits);
plotSettingsValidator.SetUseStandardScale(plotSettings, true);
plotSettingsValidator.SetStdScaleType(plotSettings, StdScaleType.ScaleToFit);
plotSettingsValidator.SetPlotCentered(plotSettings, true);
plotSettingsValidator.RefreshLists(plotSettings);
var list = plotSettingsValidator.GetCanonicalMediaNameList(plotSettings);
foreach (var name in list)
System.Diagnostics.Debug.WriteLine(name);
[b] //
// Development note: invalid input
// This is where i am getting the error I am not sure which is the invalid input.
// I have tried both a print server and a pc3 file. I have also tried A and B size, Im not sure why it would be my plot settings, it just doesnt make since to me. [/b]
plotSettingsValidator.SetPlotConfigurationName(
plotSettings,
config.ColorPrint ? config.Device.Pc3 : config.Device.NetworkLocation,
config.Size.Equals("11x17") ? "ANSI_B_(11.00_x_17.00_Inches)" : "ANSI_A_(8.50_x_11.00_Inches)");
plotInfo.OverrideSettings = plotSettings;
var plotInfoValidator
= new PlotInfoValidator
{
MediaMatchingPolicy = MatchingPolicy.MatchEnabled
};
plotInfoValidator.Validate(plotInfo);
if (PlotFactory.ProcessPlotState != ProcessPlotState.NotPlotting)
doc.Editor.WriteMessage("\nAnother plot is in progress.");
else
using (var plotEngine = PlotFactory.CreatePublishEngine())
using (var progressDialog = getProgressDialog())
{
plotEngine.BeginPlot(progressDialog, null);
plotEngine.BeginDocument(plotInfo, doc.Name, null, 1, false, doc.Name);
progressDialog.OnBeginSheet();
progressDialog.LowerSheetProgressRange = 0;
progressDialog.UpperSheetProgressRange = 100;
progressDialog.SheetProgressPos = 0;
PlotPageInfo plotPageInfo
= new PlotPageInfo
(); plotEngine.BeginPage(plotPageInfo, plotInfo, true, null);
plotEngine.BeginGenerateGraphics(null);
plotEngine.EndGenerateGraphics(null);
plotEngine.EndPage(null);
progressDialog.SheetProgressPos = 100;
progressDialog.OnEndSheet();
plotEngine.EndDocument(null);
progressDialog.PlotProgressPos = 100;
progressDialog.OnEndPlot();
plotEngine.EndPlot(null);
}
}
}