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

asterisks in custom AutoCAD command

9 REPLIES 9
Reply
Message 1 of 10
mikegera
775 Views, 9 Replies

asterisks in custom AutoCAD command

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.

 

9 REPLIES 9
Message 2 of 10
hmsilva
in reply to: mikegera

Try
(command "Layer" "off""*" "" "")

HTH
Henrique

EESignature

Message 3 of 10
mikegera
in reply to: mikegera

Thanks, but that does not work either.

 

I am in 2014, FYI, if that matters.

 

 

Message 4 of 10
hmsilva
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

EESignature

Message 5 of 10
mikegera
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?

 

 

Message 6 of 10
hmsilva
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

EESignature

Message 7 of 10
mikegera
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.

 

 

Message 8 of 10
hmsilva
in reply to: mikegera

You're welcome, mikegera

Glad I could help

 

Henrique

EESignature

Message 9 of 10
Hallex
in reply to: mikegera

In A2014 this would be robust way:

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

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 10 of 10
hmsilva
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

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost