Hi, i've got an customized command like 'mirror'. Works great as it is, however when a user cancels the command while active the osnaps are not restored. The command is like this: ^c^c^p(setq osm(getvar "osmode"));(setvar"osmode" 0);SELECT;au;\MIRROR;p;;\\N;(setvar"osmode"osm);^p The goal is: keep the osnaps as they are even when a user chooses another command or even cancels this one. Can it be done? Jan
I would usually start a lisp file with the following:- (defun MyError () (setvar "clayer" clay) (setvar "osmode" oldos) (setvar "cmdecho" cmde) ) And then define the error command within the main part of the routine using the following:- (setq *ERROR* MyError) (setq Clay (getvar "clayer")) (setq oldos (getvar "osmode")) (setq cmde (getvar "cmdecho")) This seems to work for me although being new to lisp writing I'd be interested to find out if this is the most practical way of doing things Spence
Spence, Let me suggest - checking the var's.. Like: (defun MyError () (if clay (setvar "clayer" clay)) (if oldos (setvar "osmode" oldos)) (if cmde (setvar "cmdecho" cmde)) ) If not set..causes yet another error.. Bob
Bob, Why would you need to check for the variables. Is It in case the lisp is aborted before the variables are set. I'm not questioning that you are right, but just trying to understand the reason for checking vars, Many thanks for your help Spence
Jan, The way i do is the follow I use not the setvar osmode to none. If the user cancel the command, all setting be the same because there is no difference Why using osmode? This is because while autocad draws and snap's to the current osnap settings rather than the exactly given point i.e if the given point is 1,1 and osmode is set to endpoint and thera is a object drawn to 0,0 the point witch automaticly is given by (getvar "lastpoint") switch to the endpoint 0,0 and not to 1,1 Example (command "._Line" "_Non" "1,1" "_Non" "100,1" "") (command "._Line" "0,0" "_Non" "100,0" "") I think it's not necessary to set osmode 0 in the macro because the user has it set to his preference but i am not sure Even when it's necessary i use the snap _non (this is equal to F3) for given point Experience the macro without the osmode command's Evenso you could osmode set to (setvar "osmode" 16493) it equivalent to osnap off (F3) when the user cancel the command it can restored with F3 osnap on. Cheers
It is unlikely, but possible that operator could hit escape between lines: (setq Clay (getvar "clayer"))(setq oldos (getvar "osmode")) Bob