I've developed a fairly simple in-house tool for plotting to network plotters. If I use autocad's plot dialog, I can plot multiple sheets to this plotter. My engine fails however. Multiple sheet plots with my tool will work on another one of our plotters with no errors. Another of our plotters returns the "eNotMultiPageCapable" error in AutoCAD. I can't find any literature about this error or how to account for it. Does anyone know how to solve this?
The error occurs at Autodesk.AutoCAD.PlottingServices.PlotEngine.BeginGenerateGraphics(Object parameters)
The error is persistent whether I have designated a pc3 file or directly connecting to the plotter.
This is AutoCAD 2014.
Most of the code is sourced from Kean's blog on plotting, with the exception of the user interaction/plotter selection
static public void mplot(int devicesetting, int copies) { string[] devicestoread = { "Primary Printer Device", "Secondary Printer Device", "Color Printer Device" }; string[] mediatoread = { "Primary Printer Media", "Secondary Printer Media", "Color Printer Media" }; Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; Database db = doc.Database; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); PlotInfo pi = new PlotInfo(); PlotInfoValidator piv = new PlotInfoValidator(); piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled; if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting) { string[] printsettings = { devicestoread[devicesetting], mediatoread[devicesetting] }; List<string> currentsettings = readcfg(ed, printsettings); string devname = ""; string medname = ""; if (currentsettings[0] != "" && currentsettings[1] != "") { devname = currentsettings[0]; medname = currentsettings[1]; } else { string[] devmed = ChooseDeviceAndMediaDialog(); devname = devmed[0]; medname = devmed[1]; updatecfg(ed, printsettings, devmed); } if (devname != "" && medname != "") { PlotEngine pe = PlotFactory.CreatePublishEngine(); using (pe) { List<string> alllayouts = new List<string>(); foreach (ObjectId btrId in bt) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead); if (btr.IsLayout && btr.Name.ToUpper() != BlockTableRecord.ModelSpace.ToUpper()) { Layout btrlayout = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead); alllayouts.Add(btrlayout.LayoutName); } } LayoutSelectionDialog lsd = new LayoutSelectionDialog(alllayouts); if (lsd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { List<string> selectedlayouts = lsd.selectedlayouts; ObjectIdCollection layoutsToPlot = new ObjectIdCollection(); foreach (string selectedlayout in selectedlayouts) { foreach (ObjectId btrId in bt) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead); if (btr.IsLayout && btr.Name.ToUpper() != BlockTableRecord.ModelSpace.ToUpper()) { Layout btrlayout = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead); if (btrlayout.LayoutName == selectedlayout && !layoutsToPlot.Contains(btrId)) { layoutsToPlot.Add(btrId); } } } } PlotProgressDialog ppd = new PlotProgressDialog(false, layoutsToPlot.Count, true); using (ppd) { int numSheet = 1; foreach (ObjectId btrId in layoutsToPlot) { BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrId, OpenMode.ForRead); Layout lo = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead); PlotSettings ps = new PlotSettings(lo.ModelType); ps.CopyFrom(lo); PlotSettingsValidator psv = PlotSettingsValidator.Current; psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents); psv.SetUseStandardScale(ps, true); psv.SetStdScaleType(ps, StdScaleType.ScaleToFit); psv.SetPlotCentered(ps, true); System.Collections.Specialized.StringCollection sc = psv.GetPlotStyleSheetList(); try { psv.SetCurrentStyleSheet(ps, "HP5000 Standard.ctb"); } catch { Application.ShowAlertDialog("HP5000 Standard.ctb not found. Please update Plot Style Table Search Path."); return; } psv.SetPlotConfigurationName(ps, devname, medname); pi.Layout = btr.LayoutId; LayoutManager.Current.CurrentLayout = lo.LayoutName; pi.OverrideSettings = ps; piv.Validate(pi); if (numSheet == 1) { 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); pe.BeginDocument(pi, doc.Name, null, copies, false, ""); } ppd.set_PlotMsgString(PlotMessageIndex.SheetName, doc.Name.Substring(doc.Name.LastIndexOf("\\") + 1) + " - sheet " + numSheet.ToString() + " of " + layoutsToPlot.Count.ToString()); ppd.OnBeginSheet(); ppd.LowerSheetProgressRange = 0; ppd.UpperSheetProgressRange = 100; ppd.SheetProgressPos = 0; PlotPageInfo ppi = new PlotPageInfo(); pe.BeginPage(ppi, pi, (numSheet == layoutsToPlot.Count * copies), null); pe.BeginGenerateGraphics(null); ppd.SheetProgressPos = 50; pe.EndGenerateGraphics(null); pe.EndPage(null); ppd.SheetProgressPos = 100; ppd.OnEndSheet(); numSheet++; ppd.PlotProgressPos += (100 / layoutsToPlot.Count / copies); } pe.EndDocument(null); ppd.PlotProgressPos = 100; ppd.OnEndPlot(); pe.EndPlot(null); } } } } } else { ed.WriteMessage( "\nAnother plot is in progress." ); } } }
dialogs.