How do I protect the user'
My program uses a simple error catch as the only exit point. The problem is the user can undo the setvar calls that reset the system variables and leave the variables in a undesirable state. "Undo" "C" "NONE" will make all previous actions undoable. How do we make it impossible to undo the setvar's while not blowing away the entire undo history? I use this structure:(defun c:mycommand ( / *error* ) (defun *error* ( m ) < Reset System Variables > (LM:endundo (LM:acdoc)) < ... > ) (LM:startundo (LM:acdoc)) < Set System Variables > < ... > < Reset System Variables > (LM:endundo (LM:acdoc)))With the following library functions:
;; Start Undo-Lee Mac;; Opens an Undo Group.(defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc));; End Undo-Lee Mac;; Closes an Undo Group.(defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ));; Active Document-Lee Mac;; Returns the VLA Active Document Object(defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc))When considering the order of operations & Undo Group markers within the program & error handler, be aware that when an Undo call is issued, AutoCAD will undo all operations following the end of an Undo Group before Undo'ing the Group. Thanks Lee Mac. I didn't mention I needed it to step back through a loop, but your post gave me the pattern to make it work. Now, I just need to learn the fancy VLA stuff so I quiet it down....(command "_.undo...) is noisy! You're welcome!
Temporarily disable CMDECHO
页:
[1]