Error trap and undo

Discussion in 'AutoCAD' started by Cliff Davis, Oct 16, 2003.

  1. Cliff Davis

    Cliff Davis Guest

    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] <1>: end
    Command: undo Enter the number of operations to undo or
    [Auto/Control/BEgin/End/Mark/Back] <1>: 1 -INSERT
    Command:
     
    Cliff Davis, Oct 16, 2003
    #1
  2. Cliff Davis

    Cliff Davis Guest

    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

     
    Cliff Davis, Oct 17, 2003
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.