Getting a Constant GUID for a Grasshopper Object

Hello All,

I’m writing a script that takes a bunch of geometry, packs it up into an external json file, and sends that file into an external optimization script. That optimization script sends back an output json file that I read and process back in GH. In order to do this, I need unique identifiers for each piece of geometry that sync up in both json files and the GH file. Up to this point I’ve been using GUID values for the unique identifiers, which has worked perfectly because all my geometry is coming from Rhino objects.

I’m running into issues creating consistent GUID values for geometry I’ve created in GH, however. I’m aware that only Rhino objects get assigned GUID values, but when I run an rs.coerceguid() function on the GH curves, I get GUIDS which look great, but they change each time I run the Python component. Every time the script runs or I click the ‘Test’ button, I get a different GUID for each curve. I need these to be consistent so I can pair the output json file with the GH file.

Is this possible? Ideally I need it to happen without ‘baking’ the curves to Rhino every time the script runs.

Here’s my Python code if it helps:

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

sc.doc = Rhino.RhinoDoc.ActiveDoc

crv_ids = []

for crv in crvs_in:

  • crv_id = rs.coerceguid(crv)*
  • crv_ids.append( str(crv_id) )*

sc.doc = ghdoc

crvs_out = crv_ids

Thanks so much!

Hi Christopher,

You might try to store the guid as a string in the archiveble dictionary.
On my phone so I cannot easily type up am example.
Does this link help to begin with?

Let me know if it makes sense or not and you want me to provide an example.


I’m not following exactly the purpose of this, so it’s hard to give suggestions. The GUID for Grasshopper geometry always changes because it’s always new geometry. Every time a GH solution is recomputed, all the old data is discarded and sent to the Garbage Collector. If you are trying to understand what came from where, all you need is probably a list index, right? (or, a Tree path + an index in complex cases).


Giulio Piacentino
for Robert McNeel & Associates