I'm having to turn off/freeze all layers with *REV* in the layer name. My drawings have several variations of "REV" in the name so I'm looking for some kind of wild card function to pick the names. With my bonehead knowledge of lisp I might be able to do it in a few days, if anyone has something already written out I would greatly appreciate anything you can share.
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
Something like this perhaps
(defun c:fREV ();; to off/freeze (command "Layer" "_OFF" "*REV*" "_F" "*REV*" "") (princ) ) (defun c:tREV ();; to thaw/on (command "Layer" "_T" "*REV*" "_ON" "*REV*" "") (princ) )
HTH
Henrique
@hmsilva wrote:
....
.... (command "Layer" "_OFF" "*REV*" "_F" "*REV*" "") ....
(command "Layer" "_T" "*REV*" "_ON" "*REV*" "")
....
There's really no need to turn Layers off in connection with freezing them. If you simply freeze them, the effect in the drawing will be the same, but you won't then need to turn them on when you thaw them. Also, you may well sometimes have reason to already have some of that category of Layers off at the time when you freeze them all. That differentiation will be lost if you always turn them all on in connection with thawing them, but will be preserved when you thaw them if you earlier simply froze them without also turning them off.
Here is a new loop, how do I freeze only local layers? I don't want to touch xrefs in any way. This includes layers created by xrefs named "revblock".
By the way, thanks for reminding me that I only need to freeze a layer.
@David125 wrote:
Here is a new loop, how do I freeze only local layers? I don't want to touch xrefs in any way. This includes layers created by xrefs named "revblock".
....
The tilde ~ is a "not" wildcard, and all Xref Layer names have a pipe | in them. This will freeze all local Layers other than the current one:
(command "_.layer" "_freeze" "~*|*" "")
But bear in mind that freezing a Layer will make any Xref that's inserted on it disappear, even if its own Layers are not frozen. So you would want to make sure all Xrefs are on perhaps Layer 0, or perhaps a Layer dedicated to containing Xrefs, and that Layer is current.
I'd have to think about and experiment with whether it's possible to freeze not all local Layers but only Layers with REV in their names, but not such Layers in Xrefs.... This:
(command "_.layer" "_freeze" "*REV*,~*|*" "")
doesn't work, but freezes all non-Xref Layers as the first suggestion above does. This sort of works:
(command "_.layer" "_freeze" "*REV*" "_thaw" "*|*" "")
but if you had any Xref Layers already frozen, it would undo that. It may be that you would need to step through a list of Layer names to do it.
@Kent1Cooper wrote:
There's really no need to turn Layers off in connection with freezing them. If you simply freeze them, the effect in the drawing will be the same, but you won't then need to turn them on when you thaw them. Also, you may well sometimes have reason to already have some of that category of Layers off at the time when you freeze them all. That differentiation will be lost if you always turn them all on in connection with thawing them, but will be preserved when you thaw them if you earlier simply froze them without also turning them off.
Agree.
@David125@ wrote:
Here is a new loop, how do I freeze only local layers? I don't want to touch xrefs in any way. This includes layers created by xrefs named "revblock".
By the way, thanks for reminding me that I only need to freeze a layer.
Something like this perhaps
(defun c:fREV ();; to freeze
(vl-load-com)
(vlax-for layer(vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
(if (and (wcmatch (strcase (vla-get-name layer)) "*REV*")
(not (wcmatch (vla-get-name layer) "*|*"))
(not (wcmatch (strcase (vla-get-name layer)) (strcase (getvar 'CLAYER))))
)
(vla-put-freeze layer :vlax-true)
)
)
(princ)
)
(defun c:tREV ();; to thaw
(vl-load-com)
(vlax-for layer(vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
(if (and (wcmatch (strcase (vla-get-name layer)) "*REV*")
(not (wcmatch (vla-get-name layer) "*|*"))
)
(vla-put-freeze layer :vlax-false)
)
)
(princ)
)
HTH
Henrique
Don't know why I didn't think of this sooner. Since I know our "revblock" name I put in a line to thaw layers named *revblock* after freezing all other *rev* layers. That did the trick.