Search the Community
Showing results for tags '*error*'.
-
Error message when trying to load up a *error* function lisp routine
Lee Chu Chu posted a topic in AutoLISP, Visual LISP & DCL
I have been getting this error in autocad 2015 but not in 2014 for some reason. Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended. Can anybody please help me understand what this means? I have been using this code from Afralisp (defun c:drawline () ;define function (initerr) ;intit error (setvar "cmdecho" 0) ;reset variables (setvar "osmode" 32) (command "undo" "m") ;set mark (setq pt1 (getpoint "\nPick First Point: ")) ;get points (setq pt2 (getpoint pt1 "\nPick Second Point: ")) (command "LAYER" "M" "2" "") ;change layer (command "Line" pt1 pt2 "") ;draw line (setq pt3 (getpoint pt2 "\nPick Third Point: "));get 3rd point (setvar "osmode" 0) ;reset snap (command "Line" pt2 pt3 "") ;draw line (reset) ;reset variables (princ) ) (defun error() ;load function (prompt "\nGlobal Error Trap Loaded") ;inform user (princ) );defun ;;;*========================================================== (defun initerr () ;init error (setq oldlayer (getvar "clayer")) ;save settings (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" 1) (setvar "menuecho" 0) (setvar "highlight" 1) (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" 1) (setvar "menuecho" 0) (setvar "highlight" 1) (setvar "osmode" oldsnap) (setvar "pickbox" oldpick) (princ) );defun You can find the code here: http://www.afralisp.net/autolisp/tutorials/error-trapping.php- 4 replies
-
- autocad2015
- autocad2014
-
(and 2 more)
Tagged with: