By Adam Nagy
If you want to call the UNDO command from an error handler then instead of using (command) you need to use (vla-SendCommand)
(defun C:test ()
(setq olderr error
error myerr)
(command “undo” “_m”)
(command “_line” ‘(0 0 0) ‘(10 10 0) “”)
; If you press esc when line is asking for the second point
; then myerr will be called by the system
(command “_line” ‘(0 0 0) “\” “”)
(setq *error* olderr)
)
(defun myerr (msg)
(vl-load-com)
(setq *error* olderr)
; Instead of using (command) …
; (command “_undo” “b”)
; use vla-SendCommand:
(vla-SendCommand
(vla-get-ActiveDocument
(vlax-get-acad-object))
(strcat (chr 27)(chr 27)”.undo _b “))
(princ)
)

Leave a Reply to GTCancel reply