Finding layer of object in grasshopper python

Hey everyone!!

I am trying to, given an object, find the name of the layer that object is in in the rhino document. I found that i can use rs.ObjectLayer(obj) for this. However, when i try to use it i get this error:

Runtime error (TypeErrorException): Parameter must be a Guid or string representing a Guid

The reference to the object (what im using as obj), when i print it, is something like this:
<Rhino.Geometry.Brep object at 0x0000000000000F03 [Rhino.Geometry.Brep]>
(the hexadecimal code changes everytime the code is run). I have been doing some research and it appears that this is not what a guid looks like. When using rs.GetObject() and printing the returned value, i get an guid like this: 17896771-a221-40db-88ff-1cf4d5b6a072.

How can i find the layer of the object using the reference i have for it?
How can i get the guid for the object so i can use rs.ObjectLayer(obj)?

Thanks in advance!

Can u post here how is your code?
anyway, if u use rs.GetObject() to achieve or obtain “obj” , you wont get any error if using that in rs.ObjectLayer(obj)

obj = rs.GetObject()

sorry, i don’t have access to the code at the moment, will post as soon as possible.

yes, however i cannot do that because I’m working with many objects and i need to do everything in python.