Select Rhino objects by guid

Could someone share a python, C#, or VBscript that inputs a list of guid’s and select the corresponding objects in Rhino ?

Would be much appreciated :slight_smile:

Hi Olivier ,

Something like this last line here:

import rhinoscriptsyntax as rs

id_list = ['894b6c7d-6581-4fb6-a65b-c09b4e5dc88a',
#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 (5.3 KB)

"""Provides a scripting component.
        x: The x script variable
        y: The y script variable
        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)

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


Hi Willem,

Wow, thanks !
I rather provide a list of guids rather than a simple text.

The workflow is as follows :
-Reference a bunch of geometry
-Grasshopper filters these objects (for example “objects with no names”)
-Using the guid’s of the filtered objects, select them in Rhino

In this case, it allows me to hide all the other objects in my scene an go on giving names to the un-named objects.
But this is just one example, I am likely to make more complex selections, and rather do it through GH rather than fiddling with selection filters in Rhino :

select unnamed (5.9 KB)

This script unselect all currently selected objects and then select all object with no name.

  private void RunScript(List<Guid> guids, bool Select, ref object A)
      foreach(Guid guid in guids){
        if(this.RhinoDocument.Objects.FindId(guid).Attributes.Name == null){
          this.RhinoDocument.Objects.Select(guid, true, true, true);

Edit: it can be made to work with all kind of objects. This first solution work with [Geometry pipeline] so only with simple geometry objects (visible)…

I made a list for testing, and that works already.
So if you can leave it like this and it works on both multiline strings and lists


Err… I don’t get it
If I feed a list, it complains about “Guid objects having no attribute “split””.

I Riccardo,

Thanks ! That works like a charm.
I got rid of the filter for “Has name ?” because I want to do my own filters ; this one was just a specific case.

So there : I can at last select Rhino stuff from within Grasshopper !!!

Indeed I was testing with strings and you passed guids.
I leave it be because Riccardo already provided a solution for guids.