Error trap and undo

I guess that I am misunderstanding the use of undo group, I am using the
following the following error trap to try to reset the
drawing back to it's original state.
If the function runs the (command "layer" "s" "P-FIXT-N" "") or reaches the
second "-insert" command it simply does an undo 1
completely ignoring the group, when the "esc" key is pressed. If the make
layer command was run and "esc" is pressed before the
second "-insert", the error handler is successful. When the command is
completed successfully an undo acts as a group. Is there an
explanation and/or work around for this?
In addition can anyone recommend a book that has in depth coverage of autolisp
concerning matters like this?
Thanks
Cliff
(defun c:test ()
(defun error_trap (errormessage)
(command "undo" "end")
(command "undo" "1")
(setq *error* error_back)
(graphscr)
(princ)
)
(setq error_back *error*)
(setq *error* error_trap)
(setvar "cmdecho" 1)
(command "undo" "group")
(if (tblsearch "LAYER" "P-FIXT-N")
(command "layer" "s" "P-FIXT-N" "")
(command "layer" "m" "P-FIXT-N" "c" "3" "P-FIXT-N" "lt" "CONTINUOUS"
"P-FIXT-N" "")
)
(princ "\nSelect insertion point for block: ")
(command "-insert" "pipedrop" "s" (getvar "dimscale") pause nil)
(princ "\nRotation angle: ")
(command "-insert" "pipedrop" "s" (getvar "dimscale") (getvar "lastpoint")
pause)
(command "undo" "end")
(setq *error* error_back)
)
Output:
....................
Command: undo Enter the number of operations to undo or
[Auto/Control/BEgin/End/Mark/Back] : end
Command: undo Enter the number of operations to undo or
[Auto/Control/BEgin/End/Mark/Back] : 1 -INSERT
Command:
Reply to
Cliff Davis
Loading thread data ...
following the following error trap to try to reset the
second "-insert" command it simply does an undo 1
layer command was run and "esc" is pressed before the
completed successfully an undo acts as a group. Is there an
concerning matters like this?
Reply to
TomD
Cliff,
I didn't see an UNDO BEGIN anywhere in your code. I don't do as much error trapping as I should, so don't consider me a good source of info for this particular topic. In some of my routines, however, I do something like:
(command "._UNDO" "Begin")
;code is all here
(command "._UNDO" "End")
I think this is what you want. This makes everything between these calls act line one action, as far as the UNDO command is concerned.
Cliff Davis wrote:
following the following error trap to try to reset the
second "-insert" command it simply does an undo 1
layer command was run and "esc" is pressed before the
completed successfully an undo acts as a group. Is there an
concerning matters like this?
Reply to
TomD
I should have mentioned in the post that I tried undo begin as well as undo group with the same effects. Is their a real difference between the two? Cliff
following the following error trap to try to reset the
second "-insert" command it simply does an undo 1
layer command was run and "esc" is pressed before the
completed successfully an undo acts as a group. Is there an
autolisp concerning matters like this?
Reply to
Cliff Davis
group with the same effects. Is their a real difference
Off hand, I can't answer that definitively. It's been a while since I've fooled with that, so I'll read a little before I speak further.
Reply to
TomD

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.