Toggle on/off all visible layers except for selected layer....how?

Hi,
V4
I am working over a raster plan image and at times wish to just view the plan as my workings are getting in the way !
I wish to temporarily in a quick toggle on/off sort of way, turn off visibilty for the other layers THAT ARE CURRENTLY ON, I dont want to find when I turn them back on that all layers turn on. I just want to toggle on/off all visible layers except for a selected layer, that selected layer being my plan image.

How is that done ?

I presume I would have to click on the raster image layer to let Rhino know what I wanted to remain on !
If the procedure is different then I shall go with that, but selecting the layer I still want on seems sensible and easy !

Steve

Well, if you only want to “look at” one layer, as layer state changes get recorded by the undo stack, you can use OneLayerOn and then Undo when you’re done looking to get back to where you were.

Otherwise, you can use the LayerStateManager - which can be set up as a docked panel in V5 - to set up and save one or more layer states which you can then freely switch between. Unfortunately, if you add layers to the document after that, the layer state manager will not know about them.

To get around this you could:

First, set up a layer state where the one desired layer is on and nothing else. In the layer state manager, give it a name like “SeePlan”. Then, create a button in your Rhino workspace and on the left mouse side, macro something like:

-_LayerStateManager _Save "MostRecent" _Restore "SeePlan" _Enter

That will save your current layer state (no matter what it is) and then turn off all the layers except the one you left on when you created "“SeePlan”

On the right mouse of the same button, you can then put:

-_LayerStateManager _Restore "MostRecent" _Enter

-which will bring you back to where you were. The above will work even without the layer state manager being visible or docked as a panel.

Lastly, a perhaps simpler non-layer changing workaround for your particular need:

Make a copy of the picture frame image that you are using for your plan and put it on a another layer called, say “SeePlan”. Then move the copy in Z world above all other objects in the file. Lock the layer “SeePlan” for good measure. When you turn on that layer, your plan will appear above everything else; thus it’s all you will see. When you turn it off again, you will see everything else.

HTH,
–Mitch

Hi Steve,

See if this post is helpful:

Down at the bottom Pascal is referring to his scripts page and the script to Isolate temporarily objects.
It will allow you to select the plan and isolate it for inspection, than un-isolate it again to go back to what you were doing.

NOTE:
I cannot seem to load any of the Rhino sites right now so, you as well might have to wait for it to come back online again.

EDIT:
Rhino site is back online. I can post the description of the script:

Isolate objects. Isolate objects for editing then restore the starting view and object visibility. Adds the following alias- Isolate, UnIsolate. IsolateLock, UnisolateLock, IsolateLayer, UnisolateLayer Updated 5/6/2011 added an option to save and reastore the current view or not- previous versions always saved and restored the view. Added Isolatelayer and UnisolateLayer

-Willem

1 Like

this script will do exactly what you want
RH_PY_isolateUnisolateLayer.py (1.3 KB)

Hi,
Thanks,
@Sherv_Work_Station
a 11 year wait over !
Just how do I use a PY script.
need to refresh brain.

I would want to make a button for that, is that ok and what is the coding in the button ?

Cheers

Steve

1 Like

Put this command on the button/alias:

_NoEcho !-_RunPythonScript "script\full\path.py"

Cheers,
Itching to make a button for that now.
surpised V8 hasnt such.

Steve

For me it is just turning off all the layers from the document. The previous state was some layers on and others off. After running the script I do have all the layers off. Using Rhino7 on Windows.

Hi,
thats worrying, so you say the selected layer also gets turned off ?
when its to toggle on/off all except the selected layer.
@Measure

Steve

Yes, exactly.

In this example “6MDF” is the selected layer, but “Default” is the currently active layer that stays on. I’m not sure if there’s a way for python to tell which layer is selected/highlighted in the layers panel. Otherwise, you’ll have to fully switch to the desired layer before using the script.

Yes, it is. I know this because I use a somehow similar script that selects all the objects in Selected layers.

# https://discourse.mcneel.com/t/python-script-to-select-sublayer-objects/173422/4
import scriptcontext
import rhinoscriptsyntax as rs

def SelectObjectsOnSelectedLayers():
    
    rc, indices = scriptcontext.doc.Layers.GetSelected()
    if not rc: return
    
    rh_objs = []
    
    for index in indices:
        layer = scriptcontext.doc.Layers[index]
        layer_objs = scriptcontext.doc.Objects.FindByLayer(layer)
        if layer_objs: 
            rh_objs.extend(layer_objs)
        
    rs.SelectObjects(rh_objs)

SelectObjectsOnSelectedLayers()
1 Like