Does any one know how to change GUID of ghdoc to GUID of RhinoDoc in Python of Grasshopper?
Just I want to make the same function of GUID Component using python.
GUID of ghdoc changes each times. But i want to get RhinoDoc GUID in the condition that I want to keep type hint of python component “ghdoc Object”
To deal with objects in the Rhino Document from GHPython, firstly scriptcontext.doc must be changed to the Rhino Document, then secondly the guid references to Rhino objects need to be found using the rhinoscriptsyntax functions, e.g. rs.ObjectsFromType. Otherwise the RhinoDoc objcts table must be searched directly.
These values will equal the guids seen when right clicking manually in the Rhino view pane. I don’t remember finding any other way of getting the real Rhino guid, but I’m pretty sure placing a GH geom param and selecting it from there, always produces a grasshopper guid-reference to the Rhino object, which as you’ve found changes each time the sheet is recomputed.
I tried also to change scriptcontext.doc to Rhino.Rhinodoc.ActiveDoc, and then I did scriptcontext.doc.Objects.Find( GUID of ghdoc ).
But it says, None is found.
I’m not sure what you mean by “GUID of ghdoc”. My idea only applies to the GUIDs of geometry in the Rhino document.
I’ve not tried converting them to GUIDs, but references to the ghdocs can be found via the Grasshopper developer API, especially if you have the file path of the one you want.