Select object referenced by string GUID


I have a list of strings with object GUIDs (generated previously by another script) I would like to iterate and select those objects in the viewport. Do you have any idea how to do it?

arr_guids = [“5ce968ae-276d-4bfe-b86a-fc777abbd19d”,“b2c012ea-2145-4e08-9610-010c88a4b03a”]

for guid in arr_guids:
myObject = ??? # use guid string to reference object


From the RhinDoc.Objects table use FindId.

import scriptcontext as sc

arr_guids = [...] # list of your guids

for guid in arr_guids:
    myObject = sc.doc.Objects.FindId(guid)

Thanks, but this gives you error as my list is list of strings, not objects. In reality the list will be stored in external text file, so I have to save it as strings.

Message: expected Guid, got str

Right, you need to convert to System.Guid.

from System import Guid

guid = Guid("5ce968ae-276d-4bfe-b86a-fc777abbd19d")
1 Like

Great, that is exactly it!

Thank you very much!