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?
[color=GREEN];; Start Undo - Lee Mac[/color][color=GREEN];; Opens an Undo Group.[/color]([color=BLUE]defun[/color] LM:startundo ( doc ) (LM:endundo doc) ([color=BLUE]vla-startundomark[/color] doc))[color=GREEN];; End Undo - Lee Mac[/color][color=GREEN];; Closes an Undo Group.[/color]([color=BLUE]defun[/color] LM:endundo ( doc ) ([color=BLUE]while[/color] ([color=BLUE]=[/color] 8 ([color=BLUE]logand[/color] 8 ([color=BLUE]getvar[/color] 'undoctl))) ([color=BLUE]vla-endundomark[/color] doc) ))[color=GREEN];; Active Document - Lee Mac[/color][color=GREEN];; Returns the VLA Active Document Object[/color]([color=BLUE]defun[/color] LM:acdoc [color=BLUE]nil[/color] ([color=BLUE]eval[/color] ([color=BLUE]list[/color] '[color=BLUE]defun[/color] 'LM:acdoc '[color=BLUE]nil[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color])))) (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!