UID to Geometry Failure

Halo human beings,

<<< Question:
When I try to convert the UID to the actual geometry in my Py3 component in gh file, it returns None (as shown in pic). Not sure why.

<<< Pic:

<<<Files:
IDtoGEO.zip (12.6 KB)

All kinds of things could go wrong. For starters, the user has to be an expert, familiar with this code. Because this code will only work when rs.GetObject selects a 3D Point. Anything else the user chooses, coercion to a 3Dpoint will fail, so the result will be just as shown.

Make sure scriptcontext.doc points to the same context as the 3dpoint the user selects.

UUIDs and Geometry are distinct things. Every Geom obj probably has a UUID, due t the way they’re implemented in Rhino. But billions of possible UUID values will have no Geometry object at all, so in general a UUID cannot be “converted” to Geometry.

I find it’s more helpful to think of “searching the object table of a document” for some geometry or other object with a particular UUID, instead of converting. And then also writing code to handle what should happen if no geometry is found with that UUID.

Hey James,

Thx for the reply. Just a couple of more questions:

Paragraph 1–> I think it’s free of concern for now. Cos if u download the zip package, u will find the test-piece 3dm file only contains one pnt in canvas. And the py script in gh is trying to let the user to select that point, and load that pnt in gh’s environment for further manipulation.
[Almost the same as what u do when rit click-- set one pnt, but in script way]

Paragraph 2–> could elaborate more on how to redirect the doc to the file currently active?

Paragraph 3,4-- > Totally agree!

:space_invader:

I think I cannot? Not so sure. Here’s a bit info I found from Steve.


<<< Original Post:

Hi Wally, by changing the context I mean in Grasshopper when using rhinoscriptsyntax, it’s important to both a) set scriptcontext.doc = ghdoc (the default) to work with Grasshopper objects, or scriptcontext.doc = Rhino.RhinoDoc.ActiveDoc (might need import Rhino), and then b) after your code is done with the Rhino geometry, to avoid leaving the context on the wrong one for the user’s own code or any of their other plug-ins, return it to scriptcontext.doc = ghdoc

Does coerce3dpoint expect a uuid?