Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Preceding a command with a minus problem

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
657 Views, 5 Replies

Preceding a command with a minus problem

Not sure why, but when I include the line (command "layer" "s" "0") in my code (on my Office PC) it does exactly as I expect and the current layer is set to "0", however, if I do the same thing on my PC at home it seems to fail. The 'Layer' dialog box appears, and I get the "Command Not Recognised "s"" error appear. but if I place a minus before the command ie. (command "-layer" "s" "0"), it's fine. I guess there's a variable or something that suppresses dialogs when lisp is being executed, but in my experience with lisp (about 10 years) it's never caused a problem. I've never used the "-" before the command, and it's always worked fine. If anyone can offer an explanation it would be very much appreciated. I'm using 'Acad Map 3D 2009' on both PCs. Cheers
5 REPLIES 5
Message 2 of 6
scot-65
in reply to: Anonymous

98% of the time I use ".layer" and apply this structure to all other commands that appear inside a LISP expression.
Use -layer when working with script.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 3 of 6
Anonymous
in reply to: Anonymous

I agree that is a solution (putting the minus in front), but I'm just curious as to why it behaves differently on different PCs running the same version of AutoCAD. The only difference is the OS, one is running Vista and the other XP. - Guess I'll just have to replace those lines in my code - probably several hundred of them!
Message 4 of 6
Anonymous
in reply to: Anonymous

P.S. You can achieve the same by (setvar "CLAYER" "0")
Message 5 of 6
Kent1Cooper
in reply to: Anonymous

...with one difference that I'm aware of, which may only sometimes matter:

(command "_.layer" "_set" "whatever" "")

will turn the new current Layer ON if it's OFF, whereas

(setvar 'clayer "whatever")

will leave it OFF, so you could then start to draw things you wouldn't be able to see.

I agree that it's weird that it behaves differently for the OP on two machines where the only known difference is the operating system. And I'm most surprised that the hyphen makes the difference, because it's not supposed to be relevant when calling dialog-box commands from inside a (command) function. I would hope that the period prefix would work [with or without the underscore], which ought to be preferable to the hyphen.

--
Kent Cooper


thatcadguy wrote...
P.S. You can achieve the same by (setvar "CLAYER" "0")
Kent Cooper, AIA
Message 6 of 6
Anonymous
in reply to: Anonymous

Thanks for the advice gents, I'll rewrite the code so it works in both. Forgot to mention that the Home Copy is a free 'student' version of Acad 2009, which may or may not be relavant. Not the end of the world though!!.

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report