Results 1 to 5 of 5

Thread: Error Trapping

  1. #1
    100 Club
    Join Date
    2008-11
    Location
    Fort Lewis, WA.
    Posts
    119
    Login to Give a bone
    0

    Default Error Trapping

    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.

    Code:
    (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)
    )

  2. #2
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Error Trapping

    In this Sticky thread Anatomy of an AUTOLISP file you can ( in the beginning ) read how to do.

    : ) Happy Computing !

    kennet
    Last edited by kennet.sjoberg; 2008-12-04 at 10:18 PM. Reason: ..trying to target the link.

  3. #3
    100 Club
    Join Date
    2008-11
    Location
    Fort Lewis, WA.
    Posts
    119
    Login to Give a bone
    0

    Default Re: Error Trapping

    Quote Originally Posted by kennet.sjoberg View Post
    In this Sticky thread Anatomy of an AUTOLISP file you can read how to do.

    : ) Happy Computing !

    kennet
    I will do that thanks.

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Error Trapping

    I can't manage to target the link, but look at
    "Ok, share my beer3 and lisp code (defun c: ( / ) )"


    : ) Happy Computing !

    kennet

  5. #5
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Error Trapping

    You can use the *error* function or an errortrap expression.

    See attached examples.

    Peter
    Attached Files Attached Files

Similar Threads

  1. ACADDOC.LSP error trapping
    By jasonp in forum AutoLISP
    Replies: 3
    Last Post: 2014-03-18, 05:43 PM
  2. Questions on error trapping
    By JaCAD in forum AutoLISP
    Replies: 3
    Last Post: 2011-03-04, 04:47 PM
  3. Error Trapping
    By jmcshane in forum AutoLISP
    Replies: 6
    Last Post: 2008-12-21, 02:56 AM
  4. If Statements & error trapping
    By planview in forum AutoLISP
    Replies: 0
    Last Post: 2006-05-29, 08:46 AM
  5. nested error trapping used incorrectly
    By Bob Eardley in forum AutoCAD General
    Replies: 5
    Last Post: 2005-09-14, 10:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •