Jump to content

Difficulty calling user defined functions...


TheyCallMeJohn

Recommended Posts

Hey Guys,

So I am trying to build a few tools to call in my AutoCAD functions but I am having some difficulties utilizing them. Below is a code to check and see if a layer exists. If it doesn't it creates the layer. Either way it the layer should be created at the end. I created the code "test123" to check and see if "laytool" is when it was passed a layer. I have tried several diffrent ways and searched for an answer but I haven't had any luck.

 

Also I had "laytool" working before, slightly modified to be a user defined function.

 

 

I get the following error when I run "test123"

 

Command: test123
; error: bad function: "ANNO-DIM"
Command:

Here is the original code:

 

(defun c:test123 ()
   (SETQ LAY2CHECK    "ANNO-DIM")
   (SETVAR "CLAYER" (LAYTOOL (LAY2CHECK)))
   (princ "\n ALL DONE")
)

(defun laytool (lay2check) ;Laytool R01
   (if (not (tblsearch "LAYER" lay2check)) ;Checks to see if the layer exists
       (progn
       (cond
           ((= lay2check "ANNO-DIM") (setq lay2create '("ANNO-DIM" 190 "Continuous" "P")))
           ((= lay2check "ANNO-INFCLD") (setq lay2create '("ANNO-INFCLD" 202 "Continuous" "P")))
           ((= lay2check "ANNO-NPLT") (setq lay2create '("ANNO-NPLT" 240 "Continuous" "N")))
           ((= lay2check "ANNO-RVCLD") (setq lay2create '("ANNO-RVCLD" 203 "Continuous" "P")))
           ((= lay2check "ANNO-TEXT") (setq lay2create '("ANNO-TEXT" 205 "Continuous" "P")))
           ((= lay2check "ANNO-XREF") (setq lay2create '("ANNO-XREF" 252 "Continuous" "P")))
           (T (prompt "\nLayer is not in database"))
       )
       (if (= lay2check (car lay2create))
           (COMMAND "LAYER" "M" (car lay2create) "C" (cadr lay2create) (car lay2create) "P" (nth 4 lay2create) "")
           (princ "LAYER IS NOT IN DATABASE")
       )
       )
       (princ "Layer already exists")
   )
princ()
lay2check
)

Any help would be appreciated. Thank you.

 

J

Link to comment
Share on other sites

Hi John,

 

A few things askew with your code:

 

(SETQ LAY2CHECK    "ANNO-DIM")
(LAYTOOL (LAY2CHECK))

 

LAY2CHECK is a string, not a function:

 

(LAYTOOL LAY2CHECK)

 

princ()

 

Maybe for C, but in LISP:

 

(princ)

Link to comment
Share on other sites

Well that fixed...

 

Thank you, good sir.

 

BTW: I think this is two maybe three pints I owe you now.

 

Hi John,

 

A few things askew with your code:

 

(SETQ LAY2CHECK    "ANNO-DIM")
(LAYTOOL (LAY2CHECK))

 

LAY2CHECK is a string, not a function:

 

(LAYTOOL LAY2CHECK)

 

princ()

 

Maybe for C, but in LISP:

 

(princ)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...