- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Does anyone know why I cannot read custom paper size with c# in AutoCAD 2014 and above version? I read it successfully through PlosettingValidator.GetCanonicalMediaNameList() under Acad 2012 and 2013. But failed in 2014 and 2016. The pc3 is 'DWG To PDF.pc3'.
I also call PlosettingValidator.RefreshLists() before GetCanonicalMediaNameList. Is there anything special in this API of ACAD 2014 and above?
The code snippet:
ArrayList media_list = new ArrayList();
Transaction tr = db.TransactionManager.StartTransaction();
using (tr)
{
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead);
Layout layout = (Layout)tr.GetObject(btr.LayoutId, OpenMode.ForRead);
PlotSettings ps = new PlotSettings(layout.ModelType);
ps.CopyFrom(layout);
PlotSettingsValidator psv = PlotSettingsValidator.Current;
psv.SetPlotConfigurationName(ps, devname, null);
psv.RefreshLists(ps);
StringCollection medlist = psv.GetCanonicalMediaNameList(ps);
foreach (string medname in medlist)
{
psv.SetPlotConfigurationName(ps, devname, medname);
PaperInfo pi = new PaperInfo();
pi.name = medname;
pi.local_name = psv.GetLocaleMediaName(ps, medname);
pi.width = ps.PlotPaperSize.X;
pi.height = ps.PlotPaperSize.Y;
pi.margin = ps.PlotPaperMargins;
media_list.Add(pi);
}
ps.Dispose();
psv.Dispose();
tr.Abort();
}
Solved! Go to Solution.