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

Variables in Layer Command

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
483 Views, 3 Replies

Variables in Layer Command

I am trying to pass a variable to the layer command.

 

(command "-LAYER" "C" "ccolor" "newname" "LT" "linety" "newname" "")

Where ccolor, newname and linety all can change.

 

What I am doing is renaming layers, changing their colors and linetypes then saving them.

 

Thanks

john

3 REPLIES 3
Message 2 of 4
scot-65
in reply to: Anonymous

 

(setq ccolor (getstring "Enter desired color: "))

(setq newname (getstring "Enter desired layer name: "))

(setq linety (getstring "Enter desired linetype: "))

 

(command "-LAYER" "C" ccolor newname "LT" linety newname "")

 

That should do it.

 

The only problems I see is if the string becomes empty "", or the (misspelled) layer name is not present, the program will crash.

Suggest adding

(if (and

 (> (strlen (setq a (getstring "Enter: "))) 0)

 (> (strlen (setq b (getstring "Enter: "))) 0)

 (> (strlen (setq c (getstring "Enter: "))) 0)

 (tblsearch "LAYER" b)

);and

[command...]

);if


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


Message 3 of 4
Anonymous
in reply to: scot-65

Thanks!

Your method works but I had predetermined the variables. I used what you wrote and ended up with this:

 

(setq ccolor 1 linety "HIDDEN" newname "MEHid" oldname "GT_1")
(command "rename" "la" oldname newname)
(command "-LAYER" "C" ccolor newname "LT" linety newname "")

 

 

Message 4 of 4
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

.... I had predetermined the variables. ...:

(setq ccolor 1 linety "HIDDEN" newname "MEHid" oldname "GT_1")
(command "rename" "la" oldname newname)
(command "-LAYER" "C" ccolor newname "LT" linety newname "")


If the variabels are predetermined, then they aren't really variables, so you don't really need them, and you can simplify [especially if the new layer name is shorter than its variable name!]:

 

(command

  "_.rename" "_layer" "GT_1" "MEHid"

  "_.layer" "_color" 1 "MEHid" "_linetype" "hidden" "MEHid" "")

)

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost