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
Solved! Go to Solution.
Solved by scot-65. Go to Solution.
(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.
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 "")
@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" "")
)