

(vla-put-ShadePlot plotCfg acShadePlotAsDisplayed) <- THIS IS THE LINE THE ERROR REFERENCES (setq plotCfg (vla-Add plotCfgs "DWG - 11x17 - Cyan" :vlax-true)) If the page setup exists, the variable will be of type VLA-OBJECT (setq plotCfg (vl-catch-all-apply 'vla-Item (list plotCfgs "Plot-Setup-1"))) Check to see if the pagesetup already exists (setq plotCfgs (vla-get-PlotConfigurations doc)) (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) I'm trying to set a Shade Plot setting using AutoLISP with the following code in AutoCAD 2009: (defun c:CreatePageSetup() If (layoutName "Model" And layoutName.ToLower keepLayout.ToLower) Thenĭim layoutDel As Layout = DirectCast(tr.GetObject(de.Value, OpenMode.ForRead), Layout)ĭb.SaveAs(output, False, DwgVersion.Current, db.SecurityParameters) 'db.CurrentSpaceId = de.Value => doesn't work because it's readonly '=keepLayout => doesn't work for not opened drawings Using tr As Transaction = db.TransactionManager.StartTransaction()ĭim layoutDict As DBDictionary = CType(tr.GetObject(db.LayoutDictionaryId, OpenMode.ForWrite), DBDictionary)įor Each de As DBDictionaryEntry In layoutDict

There are LayoutManager or variable CTAB which works just fine when I open drawing as a Document, but I need to do it without opening drawing.ĭb.ReadDwgFile(dwgPath, FileOpenMode.OpenForReadAndWriteNoShare, True, "") And I got stuck at this point, I haven't found any solution how to set current layout to the drawing database. So I need to set current layout to the one which will not be deleted before deleting the others. It works fine when current layout is Model or the layout which will be kept, but when current layout is the one which was deleted, it fails to open the drawing and crash AutoCAD.

I'm trying to write application which will load database of the drawing and delete all layouts except given one.
