PDA

View Full Version : Plotting in .NET



mjohnston.26901
2006-12-06, 11:18 PM
I have been trying to plot using the PlottingServices.
I haven't been able to create even the simplest plot.

Does anyone have a code example they would like to share?
A very simple one would be very helpfull.
I'm trying to stay calm. :******:

Here is my code so far:


static public void NETPlot()
{
// Set up some variables
Document ThisDrawing = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database ThisDB = ThisDrawing.Database;
string fullDWGPath = @"C:\PlotTest.dwg";
int Copies = 1;
Object parms = null;
string plotDeviceName = "WPI-8830-Full.pc3";
string styleSheet = "WPI-88xx-Full.ctb";
Point2d originPoint = new Point2d(0, 0);
// Set up some PLOT specific variables
PlotEngine pEng = PlotFactory.CreatePublishEngine();
PlotInfo pInfo = new PlotInfo();
PlotSettings pSet = new PlotSettings(true);
PlotSettingsValidator pSetValid = PlotSettingsValidator.Current;

PlotPageInfo pPInfo = new PlotPageInfo();
PlotProgressDialog pProgDialog = new PlotProgressDialog(false, 1, true);
PlotConfigManager.SetCurrentConfig(plotDeviceName);
//PlotConfigInfo pConfigInfo = new PlotConfigInfo();
PlotConfigManager.RefreshList(RefreshCode.All);
StringCollection cMNs = PlotConfigManager.CurrentConfig.CanonicalMediaNames;
string mediaName = cMNs[0].ToString();

try
{
pSetValid.SetPlotConfigurationName(pSet, plotDeviceName, mediaName);
// It was recommended to refresh lists before changing settings
pSetValid.RefreshLists(pSet);

//pSetValid.SetCanonicalMediaName(pSet, mediaName);
pSetValid.SetCurrentStyleSheet(pSet, styleSheet);
pSetValid.SetPlotCentered(pSet, false);
pSetValid.SetPlotOrigin(pSet, originPoint);
pSetValid.SetPlotPaperUnits(pSet, PlotPaperUnit.Inches);
pSetValid.SetPlotRotation(pSet, PlotRotation.Degrees000);
pSetValid.SetPlotType(pSet, Autodesk.AutoCAD.DatabaseServices.PlotType.Limits);
pSetValid.SetUseStandardScale(pSet, true);
pSetValid.SetStdScaleType(pSet, StdScaleType.StdScale3To8InchIs1ft);
pSetValid.SetZoomToPaperOnUpdate(pSet, false);
// pSetValid.SetDefaultPlotConfig(pSet);
// apply setting overrides to plot info
pInfo.OverrideSettings = pSet;

PlotInfoValidator pInfoValid = new PlotInfoValidator();
pInfoValid.Validate(pInfo);

// Settings are set - attempt plot
pEng.BeginPlot(pProgDialog, parms);
pEng.BeginDocument(pInfo, fullDWGPath, parms, Copies, false, string.Empty);
pEng.BeginPage(pPInfo, pInfo, true, parms);
pEng.BeginGenerateGraphics(parms);
pEng.EndGenerateGraphics(parms);
pEng.EndPage(parms);
pEng.EndDocument(parms);
pEng.EndPlot(parms);
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
System.Windows.Forms.MessageBox.Show(e.TargetSite + "\n" + e.StackTrace);
}
finally
{
pEng.Destroy();
}
}
[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]