Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Erik Deyo
Message 1 of 4 (510 Views)

Lisp error

510 Views, 3 Replies
10-25-2006 08:46 AM
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
*Jeff Mishler
Message 2 of 4 (510 Views)

Re: Lisp error

10-25-2006 09:17 AM in reply to: *Erik Deyo
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?
*CJ Follmer
Message 3 of 4 (510 Views)

Re: Lisp error

10-25-2006 09:37 AM in reply to: *Erik Deyo
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
Distinguished Contributor
pnorman
Posts: 614
Registered: ‎02-24-2006
Message 4 of 4 (510 Views)

Re: Lisp error

10-25-2006 11:53 AM in reply to: *Erik Deyo
Erik,

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

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

Regards
Phill
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!