Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
if I want to turn off layer prefix of "A002". How to do?
Solved! Go to Solution.
if I want to turn off layer prefix of "A002". How to do?
Solved! Go to Solution.
I am reference the below lisp.
(defun C:LAYERS_OFF (/ layobj)
(vl-load-com) ;
(foreach layname '("A002_A" "A002_B" "A002_C" "A002_D") ;
(if
(setq layobj (tblobjname "layer" layname)) ;
(progn
(vla-put-LayerOn (vlax-ename->vla-object layobj) 0) ;
(princ (strcat "\nLayer " layname " has been turned Off."))
)
)
)
(princ) ;
)
switch off either layer with the name in the list '("A002_A" "A002_B" "A002_C" "A002_D").
(defun C:LAYERS_OFF nil
(vl-load-com)
(vlax-map-collection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
'(lambda (layer) (if (and (wcmatch (vla-get-name layer) "A002*")
(minusp (vlax-get layer 'layeron))
)
(vlax-put layer 'layeron 0)
)
)
)
(princ)
)
updated
I want to switch off like below:
"A002___A"
"A002_13"
"A002"
"A00200"....etc
#4 updated
I agree with @Sea-Haven in Message 2 -- and in AutoLisp terms, nothing more than this is needed:
(defun C:YourCommandName ()
(command "_.layer" "_off" "A002*" "")
(prin1)
)
Thanks Kent, I just typed, -la off a002* enter, took what 4 seconds do we need code ? The command name as suggested by Kent "A002", say 1 second to type.