Select layer on which object is on?

unhandled
rhinolayer

#1

Hello everyone,

I am looking for a way to work more efficiently, and many times I need to hide a specific layer. I work with many layers and make2ds and sometimes it gets hard finding that one layer to turn off. Isnt there a way to:

  1. select the object. Select the layer the object is on. Turn off the layer.

Note that simply selecting all objects with same layer attribute and hiding them would not be ideal, the ideal thing would be to turn off the layer

Thank you.


(Pascal Golay) #2

Hi ShynnSup - when you have your objects selected, click on the hammer icon in Layers and choose 'Select object layer"

Does that do it?

-Pascal


#3

Hey Pascal, thats it!
Thank you!


#4

Any way this could be made into a macro/hotkey?


(Pascal Golay) #5

Hi Chris - there is not, that I know of, in plain Rhino but it should be scriptable. I’ll take a look…

Here’s a quick Python:

import scriptcontext as sc
import rhinoscriptsyntax as rs

def HighlightLayers():
    
    ids = rs.SelectedObjects()
    if not ids:return
    
    layers = [rs.ObjectLayer(id) for id in ids]
    layers = list(set(layers))
    
    for layer in layers:
        parent = rs.ParentLayer(layer)
        while parent is not None:

            rs.ExpandLayer(parent, True)
            parent = rs.ParentLayer(parent)
            
    layers = [sc.doc.Layers.FindByFullPath(layer, -1) for layer in layers]
    sc.doc.Layers.Select(layers, True)
    
if __name__ =="__main__":
    HighlightLayers()

Oh, I see Clement made something as well - you should be all set. Ah darn, - the script is V6, let me try it in V5… yeah looks like V6 only.

-Pascal


#6

Hi @pascal and @chrisariasd,

this macro seems to work for multiple objects on multiple layers:

_SelNone _-Layer _Off _Select _Pause _Enter

Note that the current layer cannot be hidden.
_
c.


#7

Thanks, that’s just what I needed!


#8

Perfect :slight_smile: thanx alot!..


#9

OneLayerOff command does it well.