I have come across a situation that has me puzzled, and I would like your thoughts on the issue.
I was working on a drawing, had probably 35 minutes worth of work done, cranking away, and started a command I couldn't follow through with yet. It was one of those,
(Thought process ...
... draw a line between these two objects, then mirror, then label.
I started the line command, then realized I was on the wrong layer for labeling the object. As habit would follow, I reached up and hit the escape key. My drawing went and 'undone' the last 35 minutes of my work. Talk about desparation. I went from desparation, into panic mode, and then anger in a really short period of time. :realmad:
My initial thoughts are my LiSP routines. Perhaps I forgot to end the undo recording commands. But I've gone through them with a finetooth comb and can't find anything missing. Perhaps my Error catching is not set properly, but I don't see anything out of place. Then again, perhaps I am not understanding error catching as well as I thought I did.
Here's a copy of one of my error catching pieces of code:
(defun c:ConvertDGN (/ *error* origTstyl origDstyl origLstyl origexpl origLayr
origColr origASN origOS dwgType dwgblocks Entity
LTnotePath BlocksInCtab dwgPreF dwgDesc TodaysDate
Text Dims LTnote
)
(vl-load-com)
(defun *error* (msg /)
(template:on-error msg)
(princ)
)
(command ".undo" "be")
(setq origTstyl (getvar "textstyle")
origDstyl (getvar "dimstyle")
...
...
;; Reset System Variables
(setq LTnotePath nil)
(setvar "osmode" origOS)
(setvar "autosnap" origASN)
(setvar "filedia" 1)
(setvar "cmdecho" 1)
(command ".undo" "E")
(ALERT "Conversion successful.")
(princ)
); end function
;; Error control Thanks to Kerry - theSwamp
(pragma '((unprotect-assign template:on-error)))
;;
(defun template:on-error (msg / tmp)
;;----- Cancel any Active Commands -----------------------------
(while
(< 0 (getvar "cmdactive"))
(command)
)
(setvar "menuecho" 1)
(command ".undo" "e" "undo" "")
;;----- Display error message if applicable _-------------------
(cond ( (not msg)) ; no error, do nothing
( (member
(strcase msg t) ; invoke a cancel
'("console break" "function cancelled" "quit / exit abort")
)
)
( (princ (strcat "\nApplication Error: " ; else, an error message
(itoa (getvar "errno"))
" :- "
msg "\n"
)
)
)
)
;;----- Reset System Variables ----------------
(setvar "osmode" origOS)
(setvar "autosnap" origASN)
(setvar "textstyle" origTstyl)
(setvar "celtype" origLstyl)
(setvar "explmode" origexpl)
(setvar "clayer" origLayr)
(setvar "cecolor" origColr)
(setvar "cmdecho" 1)
(setvar "filedia" 1)
(setvar "menuecho" 0)
(command ".redraw")
(setq *error* nil
dwgtype nil
LTnotePath nil
LTnote nil
)
(princ)
)
;;
(pragma '((protect-assign template:on-error)))
;;
So my question I guess is this, have any of you run across this situation ??
I have found that even if I have just run simple autocad commands, not running any custom lisp routines, this dilemma can still happen.
Do you guys have anything in place to help prevent this from happening ??
I was thinking about putting something like this at the end of every routine I have just to try and safeguard it, but I don't know that it will help.
(while
(< 0 (getvar "cmdactive"))
(command)
)
I don't know what is causing this nor do I know how to control it properly.
Your thoughts will be greatly appreciated, even if you just want to ramble on and tell us your own story. It may spark a thought or two on how to fix this potential disaster. Thanks.