PDA

View Full Version : Error Trapping


prose
2008-12-04, 10:33 PM
I have an error trapping question. The below lisp works fine in that it creates a layer with specified colors and thickness, lets you draw then when your done it puts you back to the "0" layer.
The problem is if you hit cancel during the command, it kicks you out and leaves you on the new layer.
The question is, can I get this routine to default back to the "0" layer if someone hits cancel during the command?
Any help would be appreciated.



(defun c:1 ()
(command "_-layer" "new" "_EFA-WIRE-FIRE"
"Lweight" ".4" "_EFA-WIRE-FIRE"
"color" "red" "_EFA-WIRE-FIRE"
"")
(command "_-layer"
"set"
"_EFA-WIRE-FIRE"
"")
(command "line")
(setq lp 1)
(while lp
(if (> (getvar "cmdactive") 0) (command pause) (progn (setq lp nil) (command "")))
);end lp
(command "layer" "set" "0" "")
(princ)
)

kennet.sjoberg
2008-12-04, 10:52 PM
In this Sticky thread Anatomy of an AUTOLISP file (http://forums.augi.com/showthread.php?t=42122#post537133) you can ( in the beginning ) read how to do.

: ) Happy Computing !

kennet

prose
2008-12-04, 10:53 PM
In this Sticky thread Anatomy of an AUTOLISP file (http://forums.augi.com/showthread.php?t=42122p=537133) you can read how to do.

: ) Happy Computing !

kennet

I will do that thanks.

kennet.sjoberg
2008-12-04, 11:44 PM
I can't manage to target the link, but look at
"Ok, share my beer3 and lisp code (defun c: :beer::beer::beer: ( / ) )"


: ) Happy Computing !

kennet

peter
2008-12-05, 11:02 PM
You can use the *error* function or an errortrap expression.

See attached examples.

Peter