Andrew1979 Posted January 25, 2015 Share Posted January 25, 2015 I have written some code that sets a 'Mark' in the 'UNDO' command before a LISP runs. My program is working as intended but if someone uses the program to draw something, then decides to type 'u' then enter, they will need to keep pressing the enter key/space bar many times to get back to before the LISP command started. My questions is, is there a way for the user to only press the 'u' key and 'enter' key once to get back to before the program started? I know they could type 'undo' then 'back' but I wanted the user to simple just type 'u'. I thought my code should work but it doesn't. The user has to keep pressing enter many times to get back to the start. Any ideas? This is the a part of how the code currently works: [color=red]([color=royalblue]defun[/color][/color] getVariables [color=red]()[/color] [color=red]([/color][color=royalblue]command[/color] [color=magenta]"undo" "mark"[/color][color=red])[/color] [color=red]([/color][color=royalblue]command[/color] [color=magenta]"undo" "begin"[/color][color=red]) [/color] [color=red]([/color][color=royalblue]setq[/color] temperr *error*[color=red])[/color] [color=red]([/color][color=royalblue]setq[/color] *error* CCerror) [color=red]([/color][color=royalblue]setq[/color] CColdlayer [color=red]([/color][color=royalblue]getvar[/color][color=magenta] "clayer"[/color][color=red]))[/color] [color=red]([/color][color=royalblue]setq[/color] CColdpickbox [color=red] ([/color][color=royalblue]getvar[/color][color=magenta] "pickbox"[/color][color=red]))[/color] [color=red]([/color][color=royalblue]setq[/color] CColdcmdecho [color=red]([/color][color=royalblue]getvar[/color] [color=magenta]"cmdecho"[/color][color=red]))[/color] [color=red]([/color][color=royalblue]setq[/color] CColdosmode [color=red]([/color][color=royalblue]getvar[/color] [color=magenta]"osmode"[/color])) [color=red]([/color][color=royalblue]setq[/color] CColdorthomode [color=red]([/color][color=royalblue]getvar[/color] [color=magenta]"orthomode"[/color][color=red]))[/color] [color=red]([/color][color=royalblue]setvar[/color] [color=magenta]"cmdecho"[/color] [color=seagreen]0[/color][color=red])[/color] [color=red]([/color][color=royalblue]setvar[/color] [color=magenta]"osmode"[/color] [color=seagreen]1[/color][color=red])[/color] [color=red] )[/color] [color=red]([/color][color=royalblue]defun[/color] setVariables [color=red]()[/color] [color=red]([/color][color=royalblue]setvar[/color] [color=magenta]"pickbox"[/color] [color=seagreen]0[/color][color=red]) [/color] [color=red]([/color][color=royalblue]setvar[/color][color=magenta] "osmode"[/color] [color=seagreen]0[/color][color=red])[/color] [color=red]([/color][color=royalblue]setvar[/color] [color=magenta]"blipmode"[/color] [color=seagreen]0[/color][color=red])[/color] [color=red])[/color] [color=red]([/color][color=royalblue]defun[/color] Restore [color=red]()[/color] [color=red]([/color][color=royalblue]setvar[/color] [color=magenta]"clayer"[/color] CColdlayer[color=red])[/color] [color=red]([/color][color=royalblue]setvar[/color][color=magenta] "pickbox"[/color] CColdpickbox[color=red])[/color] [color=red]([/color][color=royalblue]setvar [/color][color=magenta]"cmdecho"[/color] CColdcmdecho[color=red])[/color] [color=red]([/color][color=royalblue]setvar[/color] [color=magenta]"osmode"[/color] CColdosmode[color=red])[/color] [color=red]([/color][color=royalblue]setvar[/color] [color=magenta]"orthomode"[/color] CColdorthomode[color=red])[/color] [color=red]([/color][color=royalblue]command[/color][color=magenta] "undo" "end"[/color][color=red])[/color] [color=red])[/color] Quote Link to comment Share on other sites More sharing options...
Andrew1979 Posted January 25, 2015 Author Share Posted January 25, 2015 I think I have worked out the problem. The code above works fine. What I was doing was calling the (Restore) function at the end of every different drawing function rather than adding it once to the main function that calls all the other functions for the program to work.....if that makes sense. The new problem I have now though is that the 'u' command goes back to the start of the program, but the command prompt says: Command: U GROUP (Lisp Expression) (Lisp Expression) (Lisp Expression) (Lisp Expression How do I hide the (Lisp Expression) coming up??? Quote Link to comment Share on other sites More sharing options...
David Bethel Posted January 25, 2015 Share Posted January 25, 2015 While there is a vl_ cal to start an UNDO group, this is the vanilla version: (defun SetUndo () (and (zerop (getvar "UNDOCTL")) (command "_.UNDO" "_ALL")) (and (= (logand (getvar "UNDOCTL") 2) 2) (command "_.UNDO" "_CONTROL" "_ALL")) (and (= (logand (getvar "UNDOCTL") 8) (command "_.UNDO" "_END")) (command "_.UNDO" "_GROUP")) Then your *error* should contain : (setq olderr *error* *error* (lambda (msg) (while (> (getvar "CMDACTIVE") 0) (command)) (and (/= msg "quit / exit abort") (princ (strcat "\nError: *** " msg " *** "))) (and (= (logand (getvar "UNDOCTL") 8) (command "_.UNDO" "_END" "_.U")) (restore)) Quote Link to comment Share on other sites More sharing options...
Andrew1979 Posted January 28, 2015 Author Share Posted January 28, 2015 Thanks for that, I will look into it tomorrow. Quote Link to comment Share on other sites More sharing options...
MJLM Posted November 17, 2016 Share Posted November 17, 2016 I m having the same problem with this Command: U GROUP (Lisp Expression) (Lisp Expression) (Lisp Expression) (Lisp Expression I m using too a grouped undo. In my defun function I begin with (command-s "._BE") and following is my *error* function (defun *error* ( err_msg ) (colb_f) (command-s "._undo" "_E") (if (or (= err_msg "Function cancelled") (= err_msg "quit / exit abort")) (princ) (princ (strcat "\nError: " err_msg)) ) ) Everything 's working well, it's just that when I press "u" I get the annoying (Lisp Expression) multiple times. I couln"t make out the solution from the example above. Any one can help how to suppress this? Quote Link to comment Share on other sites More sharing options...
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.