View Full Version : using undo in a lisp...
timothyjturner
2006-03-03, 04:20 PM
I'm trying to use undo in my lisp...works great until I zoom in or zoom out while in the middle of a lisp. Is there anyway to ignore zooms?
Thanks!
kennet.sjoberg
2006-03-03, 04:50 PM
Try to set the UNDOCTL variable to 21
: ) Happy Computing !
kennet
timothyjturner
2006-03-03, 07:51 PM
When I add this code (setvar "undoctl" 21) , I get an error.... I looked up undoctl in the help files and to me it looks like it will only accept values between 0 and 15 and im not sure how any of these settings will solve my problem. Maybe you are using a newer version of AutoCAD than myself? I'm using AutoCAD 2005. Maybe I just don't understand? :)
kennet.sjoberg
2006-03-03, 08:14 PM
Sorry 2006
UNDOCTL System Variable
Type: Integer
Saved in: Not-saved
Initial value: 21
Indicates the state of the Auto, Control, and Group options of the UNDO command.
The setting is stored as a bitcode using the sum of the following values:
0 UNDO is turned off
1 UNDO is turned on
2 Only one command can be undone
4 Auto is turned on
8 A group is currently active
16 Zoom and pan operations are grouped as a single action
16+4+1=21 but 2006
: ) Happy Computing !
kennet
timothyjturner
2006-03-03, 08:19 PM
Yeah.... 2005 is only 0-15. That last option does not exist for me. *cries*
(Read-only)
Type: Integer
Not saved
Stores a bitcode indicating the state of the Auto and Control options of the UNDO command. It's the sum of the following values:
0 UNDO is turned off
1 UNDO is turned on
2 Only one command can be undone
4 Auto is turned on
8 A group is currently active
From your original question, I assume the zooms are between other commands. Because LISP is linearly interpreted, I don't think you can get there from here (the zooms are between commands)
I have been wrong before, though, and may have the taste of toe jam in my mouth for a while. :p
I'm not sure what you are doing with your program, but maybe look into using undo groups, or if you are drawing lines, etc., keep track of the entities created and use the entdel function to back up instead of undo.
I hope this helps,
timothyjturner
2006-03-03, 09:08 PM
Hi,
Yes, the zooms are between commands. I created a large lisp to insert and tweek many different blocks according to user inputs. Then I ask the question, "Is this okay?" If the user says no, I undo the series of commands and go back to beginning. Works great until you throw in a few zooms in between.
The undo ignores zoom and pan in this case, because the points are obtained outside of the undo group, which is when the user would zoom or pan.
Try this:
*there is no error checking and make sure OSnaps are off*
(defun c:dev1 (/ pt1 pt2)
(while (setq pt1 (getpoint "nFirst Point: "))
(setq pt2 (getpoint pt1 "nSecond Point: "))
(command "undo" "begin") ;beginning of undo group
(command "line" pt1 pt2 "")
(command "line"
(polar pt1 (+ (angle pt1 pt2) (/ pi 2)) 0.5)
(polar pt2 (+ (angle pt1 pt2) (/ pi 2)) 0.5)
""
)
(command "undo" "end") ;end of undo group
(initget "Yes No")
(if (= (getkword "Is this ok? (Yes/No)<Yes>") "No")
(command "undo" "")
) ;end if
) ;end while
) ;end defun
Maybe we just need to look at the logic.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.