Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 4
Anonymous
874 Views, 3 Replies

Lisp error

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

I'm getting this error in the following lisp. Why?

(DEFUN C:dt (/ ct curlayer tsize VS)
(SETVAR "CMDECHO" 1)
(setq
ERR *ERROR*
*ERROR* LISP-ERR
CMDECHO 1)
(SETQ CURLAYER (GETVAR "CLAYER"))
(setq ct (getvar "ctab"))
(setq NewLayer (strcat "TEXT" (substr CT 1 3)))
(COMMAND "VPLAYER" "N" NEWLAYER "")
(COMMAND "VPLAYER" "T" NEWLAYER "C" "")
(COMMAND "-LAYER" "M" NewLayer "C" "130" "" "")
(SETQ VS (/ 1 (caddr (trans '(0 0 1) 2 3))))
(setq tsize (* VS 0.125))
(SETVAR "CMDECHO" 1)
(command "_dtext" "S" "SIMPLEX" "J" pause pause tsize pause pause))
(SETVAR "CLAYER" CURLAYER)
(setvar "CMDECHO" 0)
(princ)
)
(defun
LISP-ERR (MSG)
(if (/= MSG "Function cancelled")
(princ (strcat "\nError: " MSG))
) ;_ end of if
(setvar "CLAYER" CurLAYER)
(princ)
) ;_ end of defun

--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

You are defining the (lisp-err) function outside of the function calling it,
but using a variable that is local to the (c:dt) function....move the
(lisp-err) function to be defined starting at the second line of the main
function.

"Erik Deyo" wrote in message
news:5374058@discussion.autodesk.com...
Error: AutoCAD variable setting rejected: "CLAYER" nil; error: An error has
occurred inside the *error* functionAutoCAD variable setting rejected:
"CLAYER"
nil

I'm getting this error in the following lisp. Why?
Message 3 of 4
Anonymous
in reply to: Anonymous

I used to get the same error. switching to ActiveX solved the problem for
me. Not sure what the reason was.

(vla-setvariable (vla-get-ActiveDocument (vlax-get-acad-object)) "CLAYER"
curlayer)

cj


"Erik Deyo" wrote in message
news:5374058@discussion.autodesk.com...
Error: AutoCAD variable setting rejected: "CLAYER" nil; error: An error has
occurred inside the *error* functionAutoCAD variable setting rejected:
"CLAYER"
nil

I'm getting this error in the following lisp. Why?

(DEFUN C:dt (/ ct curlayer tsize VS)
(SETVAR "CMDECHO" 1)
(setq
ERR *ERROR*
*ERROR* LISP-ERR
CMDECHO 1)
(SETQ CURLAYER (GETVAR "CLAYER"))
(setq ct (getvar "ctab"))
(setq NewLayer (strcat "TEXT" (substr CT 1 3)))
(COMMAND "VPLAYER" "N" NEWLAYER "")
(COMMAND "VPLAYER" "T" NEWLAYER "C" "")
(COMMAND "-LAYER" "M" NewLayer "C" "130" "" "")
(SETQ VS (/ 1 (caddr (trans '(0 0 1) 2 3))))
(setq tsize (* VS 0.125))
(SETVAR "CMDECHO" 1)
(command "_dtext" "S" "SIMPLEX" "J" pause pause tsize pause pause))
(SETVAR "CLAYER" CURLAYER)
(setvar "CMDECHO" 0)
(princ)
)
(defun
LISP-ERR (MSG)
(if (/= MSG "Function cancelled")
(princ (strcat "\nError: " MSG))
) ;_ end of if
(setvar "CLAYER" CurLAYER)
(princ)
) ;_ end of defun

--
Erik D.
CAD Manager
Atkinson Industries, Inc.
620-231-6900
Message 4 of 4
pnorman
in reply to: Anonymous

Erik,

Please do not double post questions on the same lisp code...

http://discussion.autodesk.com/thread.jspa?threadID=515751

Regards
Phill

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost