revink
December 1, 2025, 4:03pm
1
Hi, I am trying to do something I thought pretty simple but I am struggling in grasshopper: getting the object layer of one or multiple objects.
here is my file and the error message, what am I getting wrong? This works in the Rhino IDE but NOT in a grasshopper component
import Rhino
doc = Rhino.RhinoDoc.ActiveDoc
rhino_obj = doc.Objects.FindId(x)
if rhino_obj:
layer_index = rhino_obj.Attributes.LayerIndex
layer_item = doc.Layers\[layer_index\]
layer_name = layer_item.Name
print(layer_name)
a = layer_name
else:
print("Object not found in Rhino document")
With rhinoscriptsyntax I would just use rs.objectlayer(x)
Nothing of this works in grasshopper
identify layer.gh (3.9 KB)
Your script works fine with referenced geometry.
Once you internalise the geometry, it is no longer Rhino geometry so there is no layer…
revink
December 1, 2025, 5:00pm
3
Thanks Martin, but it still doesn’t for me, what could be the issue?
test object.3dm (64.3 KB)
revink
December 1, 2025, 5:02pm
4
see this is a referenced geometry, I get the GUID but not the layer name
Change the type hint to Guid
Are you sure you need this in a script? Grasshopper has native tools to retrieve the object layer.
1 Like
revink
December 1, 2025, 5:49pm
6
Thanks Martin that works! And thanks for pointing out there was a native tool too, I didn’t know! (Although it seems to give some additional string not needed, but I can cull that “model layer : “)
Thanks Martin, had the same issue! Any idea how to get the section style?
Cheers, Julian
wim
(Wim Dekeyser)
December 3, 2025, 9:14am
10
Hi Julian -
That’s not yet possible.
→ RH-86137 Grasshopper: Additional Layer Properties
-wim
1 Like