Getting GUID of input geometry to a Grasshopper Python component

I am trying to convert a python script I wrote as a custom command to work inside of Grasshopper as a python component.

In Rhino when I ask the user to select a polyline the return value is a GUID, which I can then pass to other methods in the RhinoScriptSyntax module.

In grasshopper when I connect a polyline into my python component I am returned a Polyline instance. I need to get the GUID of this polyline so I can feed it to the methods in the RhinoScriptSyntax module.

1 Like

What rhinoscriptsynatx function are you calling that doesn’t work with the polyline? rhinoscriptsyntax will usually work with both guids and direct geometry

The line that isn’t working is: rs.CurveCurveIntersection(line, polygon)

I was just messing around some more and managed to solve the problem though. For some reason if I set the type hint on the polygon input to Polyline then it doesn’t work. If I leave it as no type hint then everything works as expected.

Is that the expected behavior?

It’s hard to tell what is going on without seeing the definition. Either CurveCurveIntersection isn’t properly working or the type hint converting to a polyline is failing

It seems to have been able to convert to a Polyline properly as I was able to introspect the object with the dir() method. I was getting an error with the rs.CurveCurveIntersection() function that was specifically saying that a GUID was expected.

I can’t share my GH file publicly but if you want I could send it to you.

I wonder if the type hint was converting the object to a polyline in RhinoCommon which isn’t actually a curve (it is just a simple list of points). If you set the type hint to Curve, does that work?

Yes, setting it to Curve works as well.

@Alain and @piac do you think we should handle primitives like lines, polylines, or even IEnumerable in coercecurve? I haven’t thought enough about it to develop a personal opinion yet. Just thinking out loud.

@Alain @stevebaer I think we should. RH-41824 is its YT item if we go for it.

1 Like

It does sound like a good idea