Finding object reference by GUID (or name)

How would I retrieve the object reference of an object which I can identify by its name or GUID? Let us assume I have mesh named “stone” (e.g. in attached demo), I can find it by name and retrieve its GUID

import rhinoscriptsyntax as rs
dub = rs.ObjectsByName("stone")
print(dub)
print(dub[0])

this returns

[<System.Guid object at 0x000001D30EE8BA80>]
682b1c40-beeb-4799-8634-1b9c82edeedf

How would I get the object reference pointer to that “stone” object? This would empower me to directly utilize methods taking ObjRef (instead of GUID) as input reference. My below attempt

Rhino.DocObjects.Tables.ObjectTable.FindId(dub)
Rhino.DocObjects.Tables.ObjectTable.FindId(dub[0])

sadly does not work out? Any help appreciated

demo.3dm (215.8 KB)

Hi @Carsten_Keil ,

import rhinoscriptsyntax as rs
import scriptcontext
import Rhino
name = "stone"
guids = rs.ObjectsByName(name)

if guids:
    guid = guids[0]
    print("GUID:", guid)
    rhino_object = scriptcontext.doc.Objects.Find(guid)
    
    if rhino_object:
        obj_ref = Rhino.DocObjects.ObjRef(rhino_object)
        print("ObjRef:", obj_ref)
    else:
        print("Object not found in document.")
else:
    print("No object with the name 'stone' found.")

Hope this helps,
Farouk

Works like a charm! thank you very much!