Community
AutoCAD LT Forum
Welcome to Autodesk’s AutoCAD LT Forums. Share your knowledge, ask questions, and explore popular AutoCAD LT topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Toggle macro to freeze/thaw 1 layer in particular

27 REPLIES 27
SOLVED
Reply
Message 1 of 28
rhoscadman
15583 Views, 27 Replies

Toggle macro to freeze/thaw 1 layer in particular

Hi Folks,

I need a macro to toggle a single layer on and off (or freeze/thaw). At the moment I'm using the freeze layer button, but when I want to thaw it I find I need to go into the Layer command and scroll down the list to thaw it. It's the layer we keep our viewports on. And I need to turn it on and off quite frequently.

Any help would be greatly appreciated

 

Rhoscadman

27 REPLIES 27
Message 21 of 28
Charles_Shade
in reply to: rhoscadman

I get the same thing here with Help and the CUI but I did remove the <layername> (both with and without the arrows(?))and replaced this with the Layer I am hoping to toggle

Message 22 of 28
rhoscadman
in reply to: Charles_Shade

My apologies, I forgot in my haste to add the layer name.

 

^C^C$M=$(if,$(=,$(getenv,layf-t),0),setenv;layf-t;1;_-Layer;Thaw;<VPORTS>;;,setenv;layf-t;0;_-Layer;Freeze;<VPORTS>;;)^Z

 

Ignore the funny face that's supposed to be ;;)

 

cheers

Message 23 of 28
rhoscadman
in reply to: rhoscadman

blast, it's gone and done it again....................single semi colon ; and closed bracket)

Message 24 of 28
Anonymous
in reply to: rhoscadman

Yeah, I not have been as clear as I thought I was about what to replace.  Sorry about that.

 

setenv;layf-t;0;_-Layer;Freeze;<layername>;;

would be:

setenv;layf-t;0;_-Layer;Freeze;VPORTS;;

 

So, yeah, Charles, the arrows <> need to be removed.  Sorry for the confusion.  I cannot replicate this HELP and CUI business at all.  Did you guys use SETENV to give the variable a value (1 or 0) before hand?

 

You can get rid of the smileys by putting the macro in code blocks or totally per this thread if you would like.

 

(if ("mysolution"=answer) then (click "Accept As Solution"))

Message 25 of 28
Charles_Shade
in reply to: Anonymous


@Anonymous wrote:

 

 Did you guys use SETENV to give the variable a value (1 or 0) before hand?


That would be negative on the SETENV Variable.

Though that also concedes that I do not know quite what you are asking.

I thought the Macro set this at the beginning?

Message 26 of 28
Anonymous
in reply to: Charles_Shade

OK. I'll take it a little slower and explain.  Again, I apologize for the confusion.

 

The first macro:

^C^Csetenv;layf-t;\$M=$(if,$(=,$(getenv,layf-t),0),_-Layer;Thaw;layername;;,_-Layer;Freeze;layername;;)

This macro does set the variable at the beginning.  However each and every time you run it you must specify either a 1 or a 0 (freeze or thaw respectively).  Essentially, the macro asks you what you want the state (frozen or thawed) of the layer to be.  So it is not a 'true' toggle.

 

The second macro:

^C^C$M=$(if,$(=,$(getenv,layf-t),0),setenv;layf-t;1;_-Layer;Freeze;layername;;,setenv;layf-t;0;_-Layer;Thaw;layername;;)^Z

 This macro assumes that the environment variable "layf-t" is present and has a value of 0 or 1 (thaw or freeze respectively); it does not create the variable nor set its value.  You do not have to enter any values during the running of this macro.  The macro reads the value of "layf-t" and if the value is not equal to 0 (which indicates that the layer are thawed) then it freezes the layer; otherwise it thaws the layer.  Prior to running the macro you must create and set the value of "layf-t" to a 0 or 1 (depending on the current state of the layer) using SETENV.

 

Hopefully that clears up some of the confusion for you, Charles and Rhoscadman.

 

(if ("mysolution"=answer) then (click "Accept As Solution"))

Message 27 of 28
Charles_Shade
in reply to: Anonymous

Ahh... So it is a two Macro solution; not one or the other.

Now I see what I am missing. Thanks for banging my head against the wall.

Message 28 of 28


@rhoscadman wrote:
Ignore the funny face that's supposed to be ;;)

 

cheers


  Coding issues can be avoided when posting in the fourms by using the insert code option when posting

 

Thanks
Discussion_Admin

 

code button.JPG

 

 

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report