1
Layouts and printing / Re: Create a Layout and Set PlotConfiguration
« on: December 10, 2010, 12:27:01 PM »
Here's my code:
I think my issue lies in the ordering of operations, unless I've overlooked a setting?
Code: [Select]
//assumes we already created a layout with the ObjectId ltid
ObjectId ltid = lman.CreateLayout(layoutname);
Layout lt = (Layout)tr.GetObject(ltid, OpenMode.ForWrite);
{
lt.UpgradeOpen();
lt.Initialize();
//change to the one we need.
LayoutManager lytmgr = LayoutManager.Current;
lytmgr.CurrentLayout = layoutname;
//begin configuring plot settings
PlotInfo plotinf = new PlotInfo();
plotinf.Layout = lt.ObjectId;
PlotSettings plotset = new PlotSettings(lt.ModelType);
plotset.CopyFrom(lt);
PlotSettingsValidator plotsetvdr = PlotSettingsValidator.Current;
PlotInfoValidator plotvdr = new PlotInfoValidator();
Plotterused = "MyPrinter.pc3"; //for test purposes only
Papersize = "A3"; //for test purposes only
plotsetvdr.SetPlotConfigurationName(plotset, Plotterused, Papersize);
plotsetvdr.SetPlotType(plotset, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
plotsetvdr.SetUseStandardScale(plotset, true);
plotsetvdr.SetPlotRotation(plotset, PlotRotation.Degrees090);
plotsetvdr.SetPlotPaperUnits(plotset, PlotPaperUnit.Millimeters);
//if we centre the plot here, even without then changing the origin, the resultant layout still isn't centred correctly.
plotsetvdr.SetPlotCentered(plotset, true);
//commented these lines out for now as they have no overall effect on the centring of the subsequent layout.
//Point2d offset = new Point2d(0, 0);
//plotsetvdr.SetPlotOrigin(plotset, offset);
//override the current settings?
plotinf.OverrideSettings = plotset;
//validate the new settings
plotvdr.Validate(plotinf);
//sets the layout plot settings
lt.CopyFrom(plotset);
lt.TabOrder = 1;
lt.DowngradeOpen();
ed.Regen();
}I think my issue lies in the ordering of operations, unless I've overlooked a setting?