Code:
(defun foo ()
(vl-load-com)
;;check if already loaded else load
(foreach x
(list
(cons "Purge_Save" (cons :vlr-SaveComplete 'Purge_Save_S))
)
(progn
(if
;;if this
(not
(vl-position (car x)
(mapcar (function strcase)
(mapcar (function vlr-data)
(cdar
(vlr-reactors :vlr-dwg-reactor)
)
)
)
)
)
;;then this
(progn
(vlr-dwg-reactor (car x) (list(cdr x)))
)
;;else this
(princ (strcat "\n<<" (car x) " Has Already Been Loaded" ">>"))
)
)
)
;;stuff you want to do at save
(defun Purge_Save_S ()
(if
;;if this
(> (vl-file-size (strcat (getvar "dwgprefix") (getvar "dwgname"))) 15000)
;;then this
(progn
(setvar "cmdecho" 0)
(command "._purge" "all" "*" "N")
(command "._purge" "regapps" "*" "N")
(princ "\nDrawing has been purged...")
(setvar "cmdecho" 1)
(princ)
)
;;else this
(princ "Save Complete")
)
)
)
;;run once to define and load
(foo)
That's the quick version, needs error handling just in case. Purge is a little slow to be doing at each save but whatever.