Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi I'm a beginner in coding, I'm seeking some assistance on how to fix the code below. I'm currently getting errors during part ( plotSettingValidator.SetPlotConfigurationName(plotPositon, "DWG PDF.pc3", "ISO A1(841.00 x 594.00 MM)");.
I have a feeling it's something to do with the part (...,"DWG PDF.pc3"..).
[CommandMethod("simplot")]
static public void SimplePlot()
{
Document activeDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.CurrentDocument;
Editor documentEditor = activeDocument.Editor;
Database fileData = activeDocument.Database;
Transaction dwgFileInfo = fileData.TransactionManager.StartTransaction();
using (dwgFileInfo)
{
// Plotting the current layout
BlockTableRecord blockTableRecord = (BlockTableRecord)dwgFileInfo.GetObject(fileData.CurrentSpaceId, OpenMode.ForRead);
Layout layout = (Layout)dwgFileInfo.GetObject(blockTableRecord.LayoutId, OpenMode.ForRead); ;
PlotInfo plotInfo = new PlotInfo();
plotInfo.Layout = blockTableRecord.LayoutId;
PlotSettings plotPositon = new PlotSettings(layout.ModelType);
PlotSettingsValidator plotSettingValidator = PlotSettingsValidator.Current;
plotPositon.CopyFrom(layout);
//Layout of the plot with default settings
plotSettingValidator.SetPlotType(plotPositon, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
plotSettingValidator.SetUseStandardScale(plotPositon, true);
plotSettingValidator.SetStdScaleType(plotPositon, StdScaleType.StdScale1To1);
//plotSettingValidator.SetPlotCentered(plotPositon, true);
//plotSettingValidator.SetPlotConfigurationName(plotPositon, @"\\print\Pepe V2", "A4");
plotSettingValidator.SetPlotConfigurationName(plotPositon, "DWG PDF.pc3", "ISO A1(841.00 x 594.00 MM)");
plotInfo.OverrideSettings = plotPositon;
PlotInfoValidator plotInfoValidator = new PlotInfoValidator();
plotInfoValidator.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
plotInfoValidator.Validate(plotInfo);
if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
{
PlotEngine plotEnginge = PlotFactory.CreatePublishEngine();
using (plotEnginge)
{
// Create a Progress Dialog to provide info and allow the user to cancel
PlotProgressDialog dialogPlot = new PlotProgressDialog(false, 1, true);
using (dialogPlot)
{
dialogPlot.set_PlotMsgString(PlotMessageIndex.DialogTitle, "Custom Plot Progress");
dialogPlot.set_PlotMsgString(PlotMessageIndex.CancelJobButtonMessage, "Cancel Job");
dialogPlot.set_PlotMsgString(PlotMessageIndex.CancelSheetButtonMessage, "Cancel Sheet");
dialogPlot.set_PlotMsgString(PlotMessageIndex.SheetSetProgressCaption, "Sheet Set Progress");
dialogPlot.set_PlotMsgString(PlotMessageIndex.SheetProgressCaption, "Sheet Progress");
dialogPlot.LowerPlotProgressRange = 0;
dialogPlot.UpperPlotProgressRange = 100;
dialogPlot.PlotProgressPos = 0;
// Starting Plot scenario
dialogPlot.OnBeginPlot();
dialogPlot.IsVisible = true;
plotEnginge.BeginPlot(dialogPlot, null);
// We'll be plotting a single document
plotEnginge.BeginDocument(plotInfo, activeDocument.Name, null, 1, true, @"\\fileserver\users\drew.garcia\Desktop\Dummy Folder\DWG Test Files\Drawing1.dwg");
// Which contains a single sheet
dialogPlot.OnBeginSheet();
dialogPlot.LowerSheetProgressRange = 0;
dialogPlot.UpperSheetProgressRange = 100;
dialogPlot.SheetProgressPos = 0;
PlotPageInfo pageInfo = new PlotPageInfo();
plotEnginge.BeginPage(pageInfo, plotInfo, true, null);
plotEnginge.BeginGenerateGraphics(null);
plotEnginge.EndGenerateGraphics(null);
// Finish the sheet
plotEnginge.EndPage(null);
dialogPlot.SheetProgressPos = 100;
dialogPlot.OnEndSheet();
// Finish the document
plotEnginge.EndDocument(null);
// And finish the plot
dialogPlot.PlotProgressPos = 100;
dialogPlot.OnEndPlot();
plotEnginge.EndPlot(null);
}
}
}
else
{
documentEditor.WriteMessage("\nAnother plot is in progress.");
}
}
}
Solved! Go to Solution.