Use grasshopper to select Rhino objects

Hi all, if I have a few guids stored in grasshopper, how can I make them being selected in Rhino? I think there is some plugins can achieve it? Or by Ghpython?
Many thanks



Select Rhino Ojects by id.gh (7.8 KB)

  1. Place an Iron Python 2 component (I’ve not tested this in CPython3 - porting is straightforward, change System.Guid to uuid.uuid).

  2. Change the x input to list mode.

  3. Connect it to the Guid param.

  4. Open the Python component and add the following code:

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System

# Make sure they are Guids, not just strings.
guids = [System.Guid(item) for item in x]

sc.doc = Rhino.RhinoDoc.ActiveDoc

try:
    rs.SelectObjects(guids)
finally:
    sc.doc = ghdoc

If the guid objects don’t work for something, it may be necessary to search for the geometries they correspond to:

geoms = [Rhino.RhinoDoc.ActiveDoc.Objects.FindGeometry(guid) for guid in guids]

https://developer.rhino3d.com/api/RhinoScriptSyntax/#object-SelectObjects

You probably just need to change the script context to the Rhino document before calling the unselect/select rhinoscriptsyntax functions:

Cool, thanks James, thanks Anders, I will give it a shot~

Just tried and this indeed worked:


250103_SelectObjects_00.gh (5.0 KB)

Nice, thanks Anders

1 Like