Plot Engine BeginDocumnet exception error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello!
I'm trying to make plot file of DWG using AutoCAD SDK.
But, met a "eDataLinkSourceNotFound" exception message when calling Plot Engine's BeginDocument.
Pls, let me know how to handle this problem.
Thank you in advance.
The plot file generation program code as below.
===================================================================================
Document doc = IntelliCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
PromptPointOptions ppo =
new PromptPointOptions( "\nSelect first corner of plot area: ");
ppo.AllowNone = false;
PromptPointResult ppr = ed.GetPoint(ppo);
if (ppr.Status != PromptStatus.OK)
return;
Point3d first = ppr.Value;
PromptCornerOptions pco = new PromptCornerOptions("\nSelect second corner of plot area: ", first);
ppr = ed.GetCorner(pco);
if (ppr.Status != PromptStatus.OK)
return;
Point3d second = ppr.Value;
// Transform from UCS to DCS
ResultBuffer rbFrom = new ResultBuffer(new TypedValue(5003, 1)),
rbTo = new ResultBuffer(new TypedValue(5003, 2));
double[] firres = new double[] { 0, 0, 0 };
double[] secres = new double[] { 0, 0, 0 };
// We can safely drop the Z-coord at this stage
// Extents2d window = new Extents2d(firres[0],firres[1],secres[0],secres[1]);
Extents2d window = new Extents2d(first.X, first.Y, second.X, second.Y);
Transaction tr = db.TransactionManager.StartTransaction();
MessageBox.Show("First.X => " + first.X);
MessageBox.Show("First.Y => " + first.Y);
using (tr)
{
// We'll be plotting the current layout
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId,OpenMode.ForRead);
Layout lo = (Layout)tr.GetObject( btr.LayoutId,OpenMode.ForRead);
// We need a PlotInfo object
// linked to the layout
PlotInfo pi = new PlotInfo();
pi.Layout = btr.LayoutId;
// We need a PlotSettings object
// based on the layout settings
// which we then customize
PlotSettings ps = new PlotSettings(lo.ModelType);
ps.CopyFrom(lo);
// The PlotSettingsValidator helps
// create a valid PlotSettings object
PlotSettingsValidator psv = PlotSettingsValidator.Current;
// We'll plot the extents, centered and
// scaled to fit
psv.SetPlotWindowArea(ps, window);
psv.SetPlotType(ps,Teigha.DatabaseServices.PlotType.Window);
psv.SetUseStandardScale(ps, true);
psv.SetStdScaleType(ps, StdScaleType.ScaleToFit);
psv.SetPlotCentered(ps, true);
// We'll use the standard DWF PC3, as
// for today we're just plotting to file
if(ps != null)
// psv.SetPlotConfigurationName(ps,"DWF6 ePlot.pc3","ANSI_A_(8.50_x_11.00_Inches)");
psv.SetPlotConfigurationName(ps, "DWF6 ePlot.pc3", null);
// We need to link the PlotInfo to the
// PlotSettings and then validate it
pi.OverrideSettings = ps;
PlotInfoValidator piv = new PlotInfoValidator();
piv.MediaMatchingPolicy = MatchingPolicy.MatchEnabled;
piv.Validate(pi);
// A PlotEngine does the actual plotting
// (can also create one for Preview)
if (PlotFactory.ProcessPlotState == ProcessPlotState.NotPlotting)
{
PlotEngine pe = PlotFactory.CreatePublishEngine();
using (pe)
{
// Create a Progress Dialog to provide info
// and allow thej user to cancel
// PlotProgressDialog ppd = new PlotProgressDialog(false, 1, true);
// PlotProgressDialog ppd = new PlotProgressDialog(false, 1, false);
**********************************************************************************************************************
Exception Error Occurs ========> pe.BeginDocument(pi,doc.Name,null,1,true, "c:\\\\temp\\\\test-output");
**********************************************************************************************************************
// pe.BeginDocument(pi, "c:\\\\temp\\\\ABC.DWG", null, 1, true, "c:\\\\temp\\\\test-output");
PlotPageInfo ppi = new PlotPageInfo();
pe.BeginPage(ppi,pi,true,null);
pe.BeginGenerateGraphics(null);
pe.EndGenerateGraphics(null);
// Finish the sheet
pe.EndPage(null);
// Finish the document
pe.EndDocument(null);
// And finish the plot
pe.EndPlot(null);
/*
using (ppd)
{
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;
// Let's start the plot, at last
ppd.OnBeginPlot();
ppd.IsVisible = true;
pe.BeginPlot(ppd, null);
// We'll be plotting a single document
pe.BeginDocument(
pi,
doc.Name,
null,
1,
true, // Let's plot to file
"c:\\temp\\test-output"
);
// Which contains a single sheet
ppd.OnBeginSheet();
ppd.LowerSheetProgressRange = 0;
ppd.UpperSheetProgressRange = 100;
ppd.SheetProgressPos = 0;
PlotPageInfo ppi = new PlotPageInfo();
pe.BeginPage(
ppi,
pi,
true,
null
);
pe.BeginGenerateGraphics(null);
pe.EndGenerateGraphics(null);
// Finish the sheet
pe.EndPage(null);
ppd.SheetProgressPos = 100;
ppd.OnEndSheet();
// Finish the document
pe.EndDocument(null);
// And finish the plot
ppd.PlotProgressPos = 100;
ppd.OnEndPlot();
pe.EndPlot(null);
}*/
}
}
else
{
ed.WriteMessage(
"\nAnother plot is in progress."
);
}
}