Originally Posted by
de-co1
Hi All,
It feels like years since I've been in AUGI... I'm back in the game now but have never got anywhere with lisps.
I would like to know how to have a lisp run automatically. I have the following code that runs fine using the command line
Code:
(defun c:upu (/ OldLayer)
(setq OldLayer (getvar "clayer"))
(setvar "clayer" "0")
(vl-cmdf "._-purge" "all" "*" "N"); Purges all unused items.
(vl-cmdf "._-purge" "all" "*" "N"); Purges all unused items a second time, just in case.
(vl-cmdf "._-purge" "r" "*" "N"); Purges all unreferenced, registered applications.
(if (tblsearch "LAYER" OldLayer) ; Check to see if old layer still exsists
(setvar "clayer" OldLayer) ; If old layer still exists set it back to current
)
)
I firstly added the path to my own lisp folder and moved the path to the top of the support list. This lisp is also added in my startup. I read on another post that the OP's VPLOCK.lsp routine works automatically on opening a drawing and this would be handy too, but I don't understand how it runs automatically on opening. My knowledge in lisp is little to non-existent.
http://forums.augi.com/showthread.ph...=automatically
Welcome back, David!
That code defines a function named "UPU" which can be invoked by command line as such, or what is known as 'called' by using this... Which can be placed after the DEFUN statement and will result in the code being evaluated when loaded:
Code:
(defun c:UPU (/ *error* clayer)
(defun *error* (msg)
(and clayer (tblsearch "layer" clayer) (setvar 'clayer clayer))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** "))) ; Fatal error, display it
)
(princ)
)
(setq clayer (getvar 'clayer))
(setvar 'clayer "0")
(command "._undo" "_e" "._undo" "_be" "._-purge" "_a" "*" "_n"
"._-purge" "_a" "*" "_n" "._-purge" "_r" "*" "_n" "._undo"
"_e"
)
(*error* nil)
)
(c:UPU)
As for purging registry applications (aka regapps), you may find this to be of use.
Cheers