Jump to content

Too many Arguments


Enigma

Recommended Posts

Let me start off by stating that I am no LSP expert, not even a newbie. I was hoping to find an explanation as to why the lsp code pasted in below has ceased to function. Its original function, written close to 20 years ago by a long since departed employee, was to be able to enter the command SL (short for Select Layer), click on an entity on the screen you wanted to become the current layer, and voila! new current layer. I cannot remember when it stopped working, and for some reason I have grown used to working with the new acad command _ai_molc, which does the exact same thing. Regardless, when I go to use it now, I get the error: Command: sl SELECT ENTITY ON TARGET LAYER Select object: ; error: too many arguments Any Ideas?

(DEFUN C:SL (/ A2 B2 L1 L2)   (GRAPHSCR)   (PROMPT "SELECT ENTITY ON TARGET LAYER ") (TERPRI)   (SETQ A2 (ENTSEL))   (SETQ B2 (ENTGET (CAR A2)))   (SETQ L1 (ASSOC 8 B2))   (SETQ L2 (CDR L1))   (PROMPT "Setting to Layer :" L2)    (COMMAND "LAYER" "S" L2 "")

Link to comment
Share on other sites

The prompt string is missing a "strcat" to concatenate the Current Layer (L2) with "Setting to Layer: ".

 

Also, code is missing a bracket from the end.

 

I have re-written to this:

 

(defun c:sl (/ ent)
 (if (setq ent (car (entsel "\nSelect Entity on Target Layer: ")))
   (setvar "CLAYER" (cdr (assoc 8 (entget ent))))
   (princ "\n<!> Nothing Selected <!>"))
 (princ))

 

which allows for a mis-click :D

Link to comment
Share on other sites

So aside from the obvious of someone perhaps accidentally modifying the file, why would the .lsp file change? There were a few other routines that no longer worked as well, some were missing a colon or a bracket here and there. I mentioned that this file, which was only a portion of a much larger set of routines, was written a long time, and has been re-used continuously as we have have updated to all the latest releases of Autocad.

Link to comment
Share on other sites

I would only really be people editing them accidentally - they can't change any other way really - unless someone ran a LISP file that would open another LISP file and perform a (write-line) on it.. but I can't really see that happening.

 

If you have others that don't work, just post them and I'll be more than happy to sort em out for ya :)

 

Lee

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...