Menzi External Error Handler

Discussion in 'AutoCAD' started by GaryDF, Sep 27, 2004.

  1. GaryDF

    GaryDF Guest

    Juerg,

    I just wanted to thank you again for provideing me will your external function
    error handler. To save time editing a lot of routines, I added another function
    ARCH:F_CLEAN to list all of the setvars to restore.

    Works great.

    The following code modified from:
    ;;;Juerg Menzi
    ;;;MENZI ENGINEERING GmbH, Switzerland
    ;;;http://www.menziengineering.ch

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Error Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun ARCH:ERROR (Msg)
    (if (and Msg (not (eq Msg "quit / exit abort")))
    (princ Msg)
    )
    (ARCH:F_R-VAR)
    (princ "\n\n*** ///////// Program CANCELLED ///////// ***\n")
    (princ)
    )

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Clean Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun ARCH:F_CLEAN (Lst)
    (or Me:Aco (setq Me:Aco (vlax-get-acad-object)))
    (or Me:Acd (setq Me:Acd (vla-get-ActiveDocument Me:Aco)))
    (vla-StartUndoMark Me:Acd)
    (setq Me:Oer *Error*
    *Error* ARCH:ERROR
    )
    (mapcar
    '(lambda (l)
    (if (not (assoc l Me:Var))
    (setq Me:Var (append Me:Var (list (cons l (getvar l)))))
    )
    ) Lst
    )
    (princ)
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; F_S-VAR Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun ARCH:F_S-VAR ()
    (ARCH:F_CLEAN
    (list '"APERTURE" '"ATTDIA" '"ATTREQ" '"BLIPMODE" '"CECOLOR" '"CLAYER"
    '"CELTYPE"
    '"CMDECHO" '"DIMSCALE" '"DRAGMODE" '"EXPERT" '"FILEDIA"
    '"FILLETRAD"
    '"GRIDMODE" '"HIGHLIGHT" '"LUNITS" '"MENUECHO" '"MIRRTEXT"
    '"OFFSETDIST"
    '"ORTHOMODE" '"OSMODE" '"PICKBOX" '"PLINEWID" '"REGENMODE"
    '"SNAPMODE"
    '"SNAPUNIT" '"SNAPBASE" '"SNAPANG" '"SNAPSTYL" '"TEXTEVAL"
    ;;'"TEXTSTYLE"
    )
    )
    )
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; F_R-VAR Function
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun ARCH:F_R-VAR ()
    (if Me:Var
    (mapcar '(lambda (l) (setvar (car l) (cdr l))) Me:Var)
    )
    (setq *Error* Me:Oer
    Me:Oer nil
    Me:Var nil
    )
    (vla-EndUndoMark Me:Acd)
    (princ)
    )
     
    GaryDF, Sep 27, 2004
    #1
  2. GaryDF

    Jürg Menzi Guest

    Hi Gary

    Welcome...¦-)
    A little hint...
    There is no need to quote the variable names in the list:
    This syntax works also:
    '("APERTURE" "ATTDIA" "ATTREQ" "BLIPMODE" "CECOLOR" ...)

    Cheers
     
    Jürg Menzi, Sep 27, 2004
    #2
  3. GaryDF

    GaryDF Guest

    Thanks...that much I knew, I was just saving time cutting and pasting older code.

    I went ahead and made the change.

    Gary
     
    GaryDF, Sep 27, 2004
    #3
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.