Change Current Layer Command

I am trying to make a macro/alias that will change the current modeling layer to a predeterminer layer. I plan to use to as a hot key to switch to my sketch layer. I have yet to find a command that can do this. does one exist?

Additionally, I’ve been musing about setting up a more advanced macro that acts like a toggle. To execute, I would need some method to read what the current modeling layer is. Is there a command that can return that, or is there an api I can access?

Hi @cameronbehning, one easy way would be to set up a macro like below:

_-Layer _Current “YourLayerName” _Enter

Note that the layername should be in quotes if it contains spaces. An alternative to a button macro would be to dive into scripting to find out which layer is current and then set another one current it depending on whatever conditions you like.

_
c.

1 Like

Hi @cameronbehning,

Here is a possible toggle solution (RhinoScript):
ToggleCurrentLayer.rvb (1.2 KB)

You can save the script on your HD and then drag-and-drop into Rhino viewport.
It will add an alias:
ToggleCurrentLayer

From now on you can assign this macro to any alias/button/keyshortcut:
ToggleCurrentLayer TOGGLE
to switch between your one defined layer and any current layer back and forth.

Note that the default layer will be saved per-document (based on layer ID, not layer name so it can be renamed or nested under any parent), so in a new file every time you run this macro for the first time you will have to define the default layer to toggle with.
If you want to redefine the layer, simply use the command without the TOGGLE switch, there is an option for that.

hth,

–jarek

2 Likes

This is awesome! Thanks @Jarek