@Anonymous wrote:
....
The next problem is to use this command for more layers at once. Like "c015_c195-EBENE" / "c030_c210-EBENE / ... but i don't want to use the command Layers_off just one time. ....
If I understand some things correctly:
:: You do actually "want to use the command ... just one time," but to have it ask within one running of the command about multiple Layers;
:: Your J and N stand for [forgive my linguistic assumption, and adjust accordingly] Ja and Nein, but you also want the User to be able to answer with Yes or No;
then you can do the following. Some comments:
Doing the turning off via (vla-put...) means you don't need to check whether it's the current Layer, to handle it differently depending on whether it is. It does it even to the current Layer, without asking the User about it.
Using (initget)/(getkword) [read about them in Help] means it doesn't matter whether the User types in upper or lower case [so you don't need all those possibilities in your (or) function], nor whether they type just the initial or more [or all] of the word [more than the initial would fail in your version]. I included the "No" option only in case someone should choose to type that entire word, however unlikely that may be, rather than just the initial that would return "Nein." And if they hit a wrong key entirely, it asks again, instead of failing.
You could add Yes/No to the options in the prompt if you like. It currently requires an explicit answer each time [no Enter], but could be made to have a default [either way] that they can get by hitting Enter, if you like.
Lightly tested:
(defun C:LAYERS_OFF (/ layobj)
(foreach layname '("c015_c195-EBENE" "c030_c210-EBENE"); add as many as you like
(initget 1 "Ja Nein Yes No")
(if
(and
(setq layobj (tblobjname "layer" layname)); it exists
(wcmatch
(getkword (strcat "\nShould the Layer " layname " be turned Off? [Ja/Nein]: "))
"Ja,Yes"; User typed J/j/Y/y/Ja/Yes/JA/YES/Ye/jA/yEs/...
); wcmatch
); and
(vla-put-LayerOn (vlax-ename->vla-object layobj) 0); then -- turn it Off
); if
); foreach
(princ)
); defun LAYERS_OFF
(vl-load-com); if needed
Kent Cooper, AIA