trefan123 Posted September 28, 2017 Posted September 28, 2017 Good day all, In a lisp routine is there a way to reload a lisp routine if the user uses the savas command Thanks Quote
Aftertouch Posted September 28, 2017 Posted September 28, 2017 Undefine the SAVEAS command. Redefine a new SAVE ass command, that calls: .SAVEAS, then add extra line to load a lisp file (defun UNDEFINESAVEAS ( / ) (setvar "cmdecho" 0) (command ".undefine" "SAVEAS") (setvar "cmdecho" 1) (princ) ) (defun C:SAVEAS ( / ) (setvar "cmdecho" 0) (load "YOURFILE.LSP") (command ".SAVEAS") (setvar "cmdecho" 1) (princ) ) (UNDEFINESAVEAS) (princ) Quote
trefan123 Posted September 28, 2017 Author Posted September 28, 2017 Dam you blokes are good. Thanks Quote
ronjonp Posted September 28, 2017 Posted September 28, 2017 (edited) You could also use a command begin reactor. Quick example: ;; COMMAND REACTORS (or *startcommandreactor* (setq *startcommandreactor* (vlr-command-reactor nil '((:vlr-commandwillstart . strtcmd)))) ) ;; List of commands to fire reactors (set layers textstyle etc...) (setq *commands* "dim*,*table*,*xref,xattach,mview,*vports,*image*,*hatch,*leader,*text,saveas") (defun strtcmd (calling-reactor strtcmdinfo / cs name) (setq cs (strcase (car strtcmdinfo) t)) (if (wcmatch cs *commands*) (progn (cond ;; (replace the (print "*") with your code that does cool stuff ((wcmatch cs "saveas") (print "Saveas")) ((wcmatch cs "dim*") (print "Dimension")) ((wcmatch cs "*table*") (print "Table")) ((wcmatch cs "*xref,xattach") (print "Xref")) ((and (wcmatch cs "mview,*vports")) (print "Viewport")) ((wcmatch cs "*image*") (print "Image")) ((wcmatch cs "*hatch") (print "Hatch")) ((wcmatch cs "mleader") (print "Mleader")) ((wcmatch cs "*leader") (print "Leader")) ((wcmatch cs "*text") (print "Text")) ) ) ) ) Edited September 28, 2017 by ronjonp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.