Hi,
I have some code, which I use it to clean some bloated dwg files.
It seems to work but it would be better if I someone can have a look over it, only to see if there is any mistake.
Thank you
;; Load the Extended AutoLISP Functions
(vl-load-com)
;; ----------------------------------------------------------------------------
;; Delete Layer States
(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq LayCol (vla-get-Layers ActDoc))
(setq LayDict (vla-GetExtensionDictionary LayCol))
(setq LayStDict (vl-catch-all-apply 'vla-Item (list LayDict "ACAD_LAYERSTATES")))
(vlax-for State LayStDict
(vla-Delete State))
;; ----------------------------------------------------------------------------
;; Delete Layer Filters
(lambda (_vla-remove dictionary)
(_vla-remove "ACLYDICTIONARY" dictionary)
(_vla-remove "ACAD_LAYERFILTERS" dictionary))
(lambda (item dictionary)
(vl-catch-all-apply 'vla-remove (list dictionary item)))
(vla-getextensiondictionary
(vla-get-layers (vla-get-activedocument (vlax-get-acad-object))))
;; ----------------------------------------------------------------------------
;; Delete Page Setups
(setq
curdwg (vla-get-ActiveDocument (vlax-get-Acad-Object))
pslayout (vla-get-Layout (vla-get-PaperSpace curdwg)))
(vla-RefreshPlotDeviceInfo pslayout)
(vlax-for x (vla-get-Plotconfigurations curdwg)
(vla-delete x))
;; ----------------------------------------------------------------------------