*error*

Feb 13, 2007 8 Replies

Two error-messages: one loading a LISP-file, one ending a LISP-file.



LOAD failed: "C:\\Data\\AutoCAD data\\Autolisp\\demo"; error: An error has occurred inside the *error* functionAutoCAD variable setting rejected: "clayer" nil



AutoCAD variable setting rejected: "snapang" nil; error: An error has occurred inside the *error* functionAutoCAD variable setting rejected: "clayer" nil



What's going wrong here?


well, is it something you wrote, and are therefore familiar with? "clayer" is a system variable, and can't be re-defun-ed in a lisp routine. it can be reset, but not redefined.

sim with snapang

I am lousy with error handlers, I write almost entirely without and only use the routines for ME. beta.

got a code snippet to submit for review? like maybe the offending piece(s)?

I'll bet the routine has calls to SETVAR to a variable, and the variable is not yet defined.

Maybe you should post the code.

Here's the original code. It used to work without a glitch

; Routine voor het tekenen van loodrechte polylines ; geeft na een closed-polyline ; PTC/FKo

(defun *error* (wat) (princ "\n*error*: ") (princ wat) (terpri) (setq snapang_old (getvar "snapang")) (setvar "snapang" 0) (setvar "orthomode" 0) (setvar "cmdecho" 1) ) (defun c:perp(/ p p1 p2 p3 p4 p6) (setvar "cmdecho" 1) (setq p1 (getpoint "\nBeginpunt van de polyline") p2 (getpoint p1 "\nEindpunt van de eerste vertex") hoek (angle p1 p2)) (setvar "snapang" hoek) (setvar "orthomode" 1) (command "pline" p1 p2) (while (setq p (getpoint p2)) (command p) (setq p2 p) (if (= "")(setq p nil )) ) (command "u") (setq p3 (polar p1 (+ hoek (/ pi 2)) 10) p6 (polar p2 (+ hoek pi) 10) p4 (inters p1 p3 p2 p6 nil)) (command p4) (command "c") (setvar "snapang" snapang_old) (setvar "orthomode" 0) (setvar "cmdecho" 1) (princ) )

After moving the setq snapang_old and removing the error handling it works fine.

; Routine voor het tekenen van loodrechte polylines ; geeft na een closed-polyline ; PTC/FKo

(defun c:perp(/ p p1 p2 p3 p4 p6) (setq snapang_old (getvar "snapang")) (setq p1 (getpoint "\nBeginpunt van de polyline") p2 (getpoint p1 "\nEindpunt van de eerste vertex") hoek (angle p1 p2)) (setvar "snapang" hoek) (setvar "orthomode" 1) (command "pline" p1 p2) (while (setq p (getpoint p2)) (command p) (setq p2 p) (if (= "")(setq p nil )) ) (command "u") (setq p3 (polar p1 (+ hoek (/ pi 2)) 10) p6 (polar p2 (+ hoek pi) 10) p4 (inters p1 p3 p2 p6 nil)) (command p4) (command "c") (setvar "snapang" snapang_old) (setvar "orthomode" 0) (setvar "cmdecho" 1) (princ) )

It looks to me as if there's something wrong with AutoCAD's LISP-interpreter.

; Routine voor het tekenen van loodrechte polylines ; geeft na een closed-polyline ; PTC/FKo

(defun *error* (wat) (princ "\n*error*: ") (princ wat) (terpri) (setq snapang_old (getvar "snapang")) (setvar "snapang" 0) (setvar "orthomode" 0) (setvar "cmdecho" 1) ) (defun c:perp(/ p p1 p2 p3 p4 p6) (setvar "cmdecho" 1) (setq p1 (getpoint "\nBeginpunt van de polyline") p2 (getpoint p1 "\nEindpunt van de eerste vertex") hoek (angle p1 p2)) (setvar "snapang" hoek) (setvar "orthomode" 1) (command "pline" p1 p2) (while (setq p (getpoint p2)) (command p) (setq p2 p) (if (= "")(setq p nil )) ) (command "u") (setq p3 (polar p1 (+ hoek (/ pi 2)) 10) p6 (polar p2 (+ hoek pi) 10) p4 (inters p1 p3 p2 p6 nil)) (command p4) (command "c") (setvar "snapang" snapang_old) (setvar "orthomode" 0) (setvar "cmdecho" 1) (princ) )

After moving the setq snapang_old and removing the error handling it works fine.

; Routine voor het tekenen van loodrechte polylines ; geeft na een closed-polyline ; PTC/FKo

(defun c:perp(/ p p1 p2 p3 p4 p6) (setq snapang_old (getvar "snapang")) (setq p1 (getpoint "\nBeginpunt van de polyline") p2 (getpoint p1 "\nEindpunt van de eerste vertex") hoek (angle p1 p2)) (setvar "snapang" hoek) (setvar "orthomode" 1) (command "pline" p1 p2) (while (setq p (getpoint p2)) (command p) (setq p2 p) (if (= "")(setq p nil )) ) (command "u") (setq p3 (polar p1 (+ hoek (/ pi 2)) 10) p6 (polar p2 (+ hoek pi) 10) p4 (inters p1 p3 p2 p6 nil)) (command p4) (command "c") (setvar "snapang" snapang_old) (setvar "orthomode" 0) (setvar "cmdecho" 1) (princ) )

It looks to me as if there's something wrong with AutoCAD's LISP-interpreter.

Ditto on the clayer error. And I'm not sure about (setvar "snapang" hoek). Can anyone explain the hoek setting there?

"rod cohen comcast.net>" > > >

About 10 years ago I wrote this routine for easy digitizing maps with various buildings on it. It enables perpendicular angles in any direction and it closes the polyline with a last perpendicular line.

The point is that AutoCAD tells An error has occurred inside the *error* function. How come? Is AutoCAD drunk :? Apparently not, after one day of rest the original file still doesn't work. :( But then again, what is wrong with the *error* handling and how can I get it right (without having to re-install AutoCAD)? I'm now working with 2007, but I recall the fault when working with R14. Especially the AutoCAD variable setting rejected: "clayer" nil. happened in routines where clayer was not used...

"rod cohen comcast.net>" > > >

I am on an old version of Autocad. this is just a hunch.

type (terpri) at the command line and see if 07 interprets it correctly. if there is an abondonded piece of code, that looks suspicious to me.

otherwise I would load VLISP and run the code line by line til it fails.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required