Select Rhino objects by guid

Hi Olivier ,

Something like this last line here:

import rhinoscriptsyntax as rs

id_list = ['894b6c7d-6581-4fb6-a65b-c09b4e5dc88a',
           '501983de-d55b-417d-92d2-9ce7b1cc78ee', 
           'd12c3658-0824-4471-9b77-a9ba801eda16', 
           'd17e0228-af5b-4f19-8853-2f0205a3168d']
           
#this line of could could/should be enough to select all objects in the list
for listed_id in id_list: rs.SelectObject(listed_id)

But maybe you need to add some code to make it work in grasshopper as I suspect you want to use it there?
I made a gh version that operated from within a python component:
image
select_idlist.gh (5.3 KB)

"""Provides a scripting component.
    Inputs:
        x: The x script variable
        y: The y script variable
    Output:
        a: The a output variable"""

__author__ = "Willem"
__version__ = "2019.09.26"

import rhinoscriptsyntax as rs
import Rhino
import System
doc = Rhino.RhinoDoc.ActiveDoc

separate_lines = id_list.split('\n')

for str_id in separate_lines:
    obj_id = System.Guid(str_id)
    rhobj = doc.Objects.Find(obj_id)
    rhobj.Select(True)

Maybe you should also define how that list is defined?
I now assumed a single text with on each line the string of the id

-Willem

2 Likes