Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
mikegera
Posts: 64
Registered: ‎05-31-2013
Message 1 of 10 (323 Views)

asterisks in custom AutoCAD command

323 Views, 9 Replies
01-15-2014 04:08 PM

I want to write a very simple program that will turn all layers OFF except the current layer, which I *think* would look something like this:

 

; "LOFF" command (turn all layers OFF except current layer)
(defun c:loff ()
  (command "-la" "OFF" "*" "n")
  (princ)
)

 

Yet this does not work.  What am I doing wrong?  Is it something to do with the astericks?

 

Thanks for any help as always.

 

*Expert Elite*
hmsilva
Posts: 3,327
Registered: ‎12-17-2004
Message 2 of 10 (318 Views)

Re: asterisks in custom AutoCAD command

01-15-2014 04:14 PM in reply to: mikegera
Try
(command "Layer" "off""*" "" "")

HTH
Henrique
Valued Contributor
mikegera
Posts: 64
Registered: ‎05-31-2013
Message 3 of 10 (307 Views)

Re: asterisks in custom AutoCAD command

01-15-2014 04:42 PM in reply to: mikegera

Thanks, but that does not work either.

 

I am in 2014, FYI, if that matters.

 

 

*Expert Elite*
hmsilva
Posts: 3,327
Registered: ‎12-17-2004
Message 4 of 10 (304 Views)

Re: asterisks in custom AutoCAD command

01-15-2014 04:47 PM in reply to: mikegera

mikegera wrote:

Thanks, but that does not work either.

 

I am in 2014, FYI, if that matters.

 

 


Works for me, AC2010/2012/2014

 

EDITED

Try your code:

 

; "LOFF" command (turn all layers OFF except current layer)
(defun c:loff ()
  (command "-layer" "OFF" "*" "n" "")
  (princ)
)

 

Henrique

Valued Contributor
mikegera
Posts: 64
Registered: ‎05-31-2013
Message 5 of 10 (298 Views)

Re: asterisks in custom AutoCAD command

01-15-2014 04:56 PM in reply to: hmsilva

That does not work either.  Is there a way I can save some sort of output file when I run an AutoLISP file so we can see what is going on?

 

 

*Expert Elite*
hmsilva
Posts: 3,327
Registered: ‎12-17-2004
Message 6 of 10 (296 Views)

Re: asterisks in custom AutoCAD command

01-15-2014 04:59 PM in reply to: mikegera

I have edited the previous post, test it...

 

"Is there a way I can save some sort of output file when I run an AutoLISP file so we can see what is going on?"

 

In a command call, affter running the code, press F2
For more complex codes, read this Lee Mac Tutorial


HTH
Henrique

Valued Contributor
mikegera
Posts: 64
Registered: ‎05-31-2013
Message 7 of 10 (278 Views)

Re: asterisks in custom AutoCAD command

01-15-2014 05:41 PM in reply to: hmsilva

I see what  I did now.  Wow, what a stupid mistake on my part.  Using "la" instead of "layer".  I am so used to entering "la" at the command line.  The F2 thing helped identify that problem instantly.  Thanks.

 

An additional "" is required at the end, by the way, or you'll be left hanging. 

 

Thanks.

 

 

*Expert Elite*
hmsilva
Posts: 3,327
Registered: ‎12-17-2004
Message 8 of 10 (249 Views)

Re: asterisks in custom AutoCAD command

01-16-2014 12:54 AM in reply to: mikegera

You're welcome, mikegera

Glad I could help

 

Henrique

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 9 of 10 (243 Views)

Re: asterisks in custom AutoCAD command

01-16-2014 01:17 AM in reply to: mikegera

In A2014 this would be robust way:

(defun c:loff ()
  (initcommandversion)
  (command "_.-layer" "_OFF" "*" "_N" "")
  (princ)
)

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
*Expert Elite*
hmsilva
Posts: 3,327
Registered: ‎12-17-2004
Message 10 of 10 (241 Views)

Re: asterisks in custom AutoCAD command

01-16-2014 01:21 AM in reply to: Hallex

Hallex wrote:

In A2014 this would be robust way:

(defun c:loff ()
  (initcommandversion)
  (command "_.-layer" "_OFF" "*" "_N" "")
  (princ)
)

 


Good catch, Hallex!

 

Henrique

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.