GhPython print objs' layername

Hi all,
I am trying let Ghpython print out all the selected objects’ layername. I can do it in rhinopython but cannot do the same thing in GhPython, does anyone know why? Did it miss something very basic?
Many thanks,


Print Objs’ Layername.gh (3.9 KB)
Print Objs’ Layername.py (145 Bytes)

If you load the objects into grasshopper, they become part of the grasshopper document, and will not have the attributes attached to it. Basically it’s the same as doing a rs.coercerhinoobject() in Rhino Python.
Also read the error message: if you want to do something with the doc objects, you need to set the context to the Rhino doc.

Thanks Gijs, in this case, how can I make it compatible with the GhPython script?

it’s not clear to me what you want to do, if you load your objects into gh, they will not be on a layer

Have a look here:

1 Like

Here the Python objs input is set to Guid.

Print Objs’ Layername_V2.gh (5.3 KB)

1 Like

Thanks Anders and Adam, this is what I am after~

1 Like