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)
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
Place an Iron Python 2 component (I’ve not tested this in CPython3 - porting is straightforward, change System.Guid
to uuid.uuid
).
Change the x input to list mode.
Connect it to the Guid param.
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~
Nice, thanks Anders