Selecting the subject layer main layer

Greetings to all,

When I select the product as in the picture, is there a sctrip where I can select all the layers in the main layer it is on?

If I understood you correctly, this outta do it.

from Rhino.Input import RhinoGet as rget
import Rhino as rh
import scriptcontext as sc

L = sc.doc.Layers
r,oref = rget.GetOneObject("select ", False, rh.DocObjects.ObjectType.AnyObject)
li = oref.Object().Attributes.LayerIndex
l = L.FindIndex(li)
pl = L.FindId(l.ParentLayerId)
kins = pl.GetChildren()
L.Select([i.Index for i in kins], True)

yes but I’m getting such an error, how do I solve2020-02-04_13-27-44

What version of Rhino are you using, V5 or V6? V5 does not have a LayerTable.FindIndex method.

Also, are you looking to select the layers in the layer panel, or the objects on those layers?

V5 .

OK, I only have scripts for selecting the objects on the layers, not highlighting the layers in the layer panel.

THANK YOU I wrote the same similar file but I couldn’t offer another solution

can you throw a video on how the selection codes of the objects in the layer works

Here are three scripts…

Select one or more layers from the popup dialog, it will select all the objects on that layer plus any on sublayers under that layer (down as many levels as needed) (1.1 KB)

Select one or more objects, it will select all the objects on the same layer plus any objects on sublayers under that layer (down as many levels as needed) (875 Bytes)

Same as above, but also selects “up” the tree to the top level layer if the object(s) selected are on sublayers (as well as down the tree). (1020 Bytes)

I see one is missing, that would be same as #3, but selecting layers from the list instead of objects. I will look into putting that together.

Note that the script that involves choosing layers above does so from a separate popup dialog, it does not look at highlighted layers in the Layers panel.