Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Computer Aided Design - CAD > Autodesk software > AutoCAD 2008: G...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 4173 of 4251
Post > Topic >>

AutoCAD 2008: Global Error Checking Lisp

by strawberry <zac.carey@[EMAIL PROTECTED] > Mar 25, 2008 at 02:37 AM

Hi,

I'm trying to build a global error checking routine such that, if a
custom lisp command is escaped mid-way through, the user's settings
are returned to their previous state (i.e. before the command was
issued).

I found just such a routine at http://www.afralisp.net/lispa/lisp6.htm
and have attempted to adapt it for my purposes but something's not
right. For instance osnaps are not restored to their original setting.

Below, I've included the handful of statements that top and tail my
own custom lisp routine, together with the  error checking routine
(slightly modified from the original). Any thoughts:

--
(defun c:gea ()
   (initerr)                 ;error checking
   (command "_.undo" "_g")...

....(command "_.undo" "_end")
   (reset)
   (princ)
)
--



;;;error trapping, based on a script provided by K. Ramage at
;;;http://www.afralisp.net/lispa/lisp6.htm

(defun error()					;load function
(prompt "\nGlobal Error Trap Loaded")			;inform user
(princ)
);defun
;;;*==========================================================
(defun initerr ()					;init error
  (setq oldlayer (getvar "clayer"))			                ;save settings
  (setq oldblipmode (getvar "blipmode"))
  (setq oldmenuecho (getvar "menuecho"))
  (setq oldhighlight (getvar "highlight"))
  (setq oldcmdecho (getvar "cmdecho"))
  (setq oldlunits (getvar "lunits"))
  (setq oldsnap (getvar "osmode"))
  (setq oldpick (getvar "pickbox"))
  (setq temperr *error*)				;save *error*
  (setq *error* trap)					;reassign *error*
  (princ)
);defun
;;;*===========================================================
(defun trap (errmsg)					;define trap
  (command nil nil nil)
  (if (not (member errmsg '("console break" "Function Cancelled"))
      )
    (princ (strcat "\nError: " errmsg))			;print message
  )
  (command "undo" "b")				;undo back
  (setvar "clayer" oldlayer)				;reset settings
  (setvar "blipmode" oldblipmode)
  (setvar "menuecho" oldmenuecho)
  (setvar "highlight" oldhighlight)
  (setvar "cmdecho" oldcmdecho)
  (setvar "lunits" oldlunits)
  (setvar "osmode" oldsnap)
  (setvar "pickbox" oldpick)
  (princ "\nError Resetting Enviroment ")		                ;inform
user
  (terpri)
  (setq *error* temperr)				;restore *error*
  (princ)
);defun
;;;*===========================================================
(defun reset ()					;define reset
  (setq *error* temperr)				;restore *error*
  (setvar "clayer" oldlayer)				;reset settings
  (setvar "blipmode" oldblipmode)
  (setvar "menuecho" oldmenuecho)
  (setvar "highlight" oldhighlight)
  (setvar "cmdecho" oldcmdecho)
  (setvar "lunits" oldlunits)
  (setvar "osmode" oldsnap)
  (setvar "pickbox" oldpick)
  (princ)
);defun
;;;*======================================================
(princ)




 1 Posts in Topic:
AutoCAD 2008: Global Error Checking Lisp
strawberry <zac.carey@  2008-03-25 02:37:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 4 0:45:23 CDT 2008.