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

Trying to freeze layers by using wildcard layer name

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
David125
3113 Views, 8 Replies

Trying to freeze layers by using wildcard layer name

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.

8 REPLIES 8
Message 2 of 9
hmsilva
in reply to: David125

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

EESignature

Message 3 of 9
David125
in reply to: hmsilva

Thank you! It works like a champ.

Message 4 of 9
hmsilva
in reply to: David125

You're welcome, David
Glad I could help

Henrique

EESignature

Message 5 of 9
Kent1Cooper
in reply to: hmsilva


@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.

Kent Cooper, AIA
Message 6 of 9
David125
in reply to: Kent1Cooper

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.

Message 7 of 9
Kent1Cooper
in reply to: David125


@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.

Kent Cooper, AIA
Message 8 of 9
hmsilva
in reply to: Kent1Cooper


@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

 

 

EESignature

Message 9 of 9
David125
in reply to: Kent1Cooper

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.

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

Post to forums  

Autodesk Design & Make Report

”Boost