Jump to content
Enigma

Too many Arguments

Recommended Posts

Enigma

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 "")

Share this post


Link to post
Share on other sites
Lee Mac

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

Share this post


Link to post
Share on other sites
Enigma

You guys are Gods! Thanks! :D

Share this post


Link to post
Share on other sites
Lee Mac

No Probs, if you have any other questions, just ask :D

 

Lee

Share this post


Link to post
Share on other sites
Enigma

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.

Share this post


Link to post
Share on other sites
Lee Mac

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×