Setting configname for a layout generates an error

<?xml encoding=”UTF-8″>By Daniel Du

Issue

Why do I get an error when I try to set the ConfigName of a Layout?

Solution

The usual reason for this error is that you are not calling ‘RefreshPlotDeviceInfo’ before assigning a ‘ConfigName’.

Here is an example of some VBA code that does work:

Sub Test()<br>Dim Layouts As AcadLayouts<br>Dim Layout As AcadLayout<br><br>' Get the files preferences object<br>Set Layouts = ThisDrawing.Layouts<br><br>' Change plotter configuration file<br>Layouts("Model").RefreshPlotDeviceInfo<br>Layouts("Model").ConfigName = "PrinterName"<br><br>ThisDrawing.Plot.PlotToDevice<br>End Sub

If you comment out the line ‘Layout(“Model”).RefreshPlotDeviceInfo’, the routine will work sometimes, but not always.

Please note that you will still generate an error if you try to set a ConfigName that AutoCAD cannot find.


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading