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 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!