I am trying to get the ability to change the layout size of a given drawing two different ways.
1. If I already know the size of the layout and it is not 8.5 x 11 I want to set it to say 24 x 36.
2. If I do not know the size already I need to calculate it based on the zoom all of the model space or the title block size already in the paperspace.
Here is how I have at least pulled the paperspace size but I am not sure how to change it I have seen posts here and on Autodesk Forums that you can not use the Paperspace table is that correct? I have tried a few more things but at this time I am just spinning my wheels and basicly hacking code. I have looked through the ACAD.NET API docs but it is erroring out on me when I set the plotsettings for the psv.
{Code}
public static void pltSetup()
{
Document acDoc = acApp.DocumentManager.MdiActiveDocument;
Editor acEd = acDoc.Editor;
Database acDB = acDoc.Database;
using (Transaction acTran = acDB.TransactionManager.StartTransaction())
{
LayoutManager objLm = LayoutManager.Current;
ObjectId layID = objLm.GetLayoutId("Layout1");
Layout lay = acTran.GetObject(layID,OpenMode.ForRead) as Layout;
Extents2d lyMargins = lay.PlotPaperMargins;
//Point2d lyPaper = lay.PlotPaperSize;
PlotInfo pi = new PlotInfo();
pi.Layout = lay.ObjectId;
PlotSettings ps = new PlotSettings(lay.ModelType);
ps.CopyFrom(lay);
PlotSettingsValidator psv = PlotSettingsValidator.Current;
psv.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents);
psv.SetPlotCentered(ps,true);
psv.SetPlotWindowArea(ps,lyMargins);
psv.SetPlotConfigurationName(ps, "None", "ARCH D(24.00 x 36.00)");
lay.UpgradeOpen();
lay.CopyFrom(ps);
acTran.Commit();
acTran.Dispose();
}
}
{/Code}