Speaking of purging, I frankensteined this from bits and pieces I found on the swamp a long time ago. It typically cuts down a drawing size by 50%. Seriously.
It saves the drawing when it's finished, btw, in case you didn't notice that right off.
I use this in place of 'qsave' quite often.
(defun c:qc (/)
(vl-Load-Com)
(vl-Catch-All-Apply
'(lambda ()
(vla-Remove
(vla-GetExtensionDictionary
(vla-Get-Layers
(vla-Get-ActiveDocument
(vlax-Get-Acad-Object)
)
)
)
"ACAD_LAYERFILTERS"
)
)
)
(setvar "cmdecho" 0)
(setq A (reverse (dictsearch (namedobjdict) "ACAD_GROUP")))
(while (setq B (cdr (assoc 350 A)))
(setq C (entget B))
(setq D (assoc 340 C))
(if (= D nil)
(entdel B)
)
(setq A (cdr (cdr A)))
)
(setvar "cmdecho" 0)
(if (= (tblsearch "style" "STANDARD") nil)
(command "-style" "STANDARD" "SIMPLEX" "0" "1.0" "0" "N" "N" "N")
)
(if (= (tblsearch "Dimstyle" "STANDARD") nil)
(command "-dimstyle" "s" "STANDARD")
)
(command "-dimstyle" "r" "STANDARD")
(setvar "TEXTSTYLE" "STANDARD")
(setvar "CLAYER" "0")
(command "-purge" "a" "*" "n")
(command "-purge" "a" "*" "n")
(command "-purge" "a" "*" "n")
(command "qsave")
(princ)
(princ
"\nAll layer filters have been deleted, all empty groups have been deleted and everything else has been purged. Drawing has been saved."
)
(princ)
)