Issue with PolylineCurve Output in Custom Plugin (GHPython)

Hi everyone,

I’m developing a custom Rhino 8 plugin using the RhinoScript editor, and I’m encountering an issue when trying to output PolylineCurves generated from a CPython script.

My script generates streamlines. It works fine when running the code within GHPython or as a Grasshopper user object. However, when I package it as a Rhino plugin, the output of the component displays the following instead of actual curves:

<Rhino.Geometry.PolylineCurve object at 0x00000176561EE1C0>
<Rhino.Geometry.PolylineCurve object at 0x0000017656256200>
...

I tried converting the PolylineCurves to NurbsCurves using ToNurbsCurve() and ensuring the output type is set to “Curve” in Grasshopper. Now, when I connect the output to other Grasshopper components, I get this error in the Grasshopper Breakpoint window:

The supplied data could not be converted.  
Parameter type: GH_Curve, Supplied type: PyObject

The same problem occurs with Point3d objects for the seed points.

Here’s an example of how I’m processing the output:

# Convert PolylineCurves to NurbsCurves
gh_stream_lines = []
for curve in streamlines:
    if curve is not None:
        try:
            nurbs = curve.ToNurbsCurve()
            gh_stream_lines.append(nurbs)
        except Exception as e:
            print("Error converting curve:", e)
stream_lines = gh_stream_lines

Even with these conversions, the issue persists.

Has anyone encountered a similar problem when packaging GHPython scripts into plugins? Any suggestions for resolving this conversion issue would be greatly appreciated!

Thanks in advance for your help! :pray:

Maybe try wrapping them in GH_ObjectWrapper, which forces a Grasshopper-compatible data type?

nurbs = curve.ToNurbsCurve()
gh_stream_lines.append(ght.GH_ObjectWrapper(nurbs))  # Wrap in GH-compatible type

Hope this help

Thank you for your reply.
I tried, the script itself works but I still get the same issue: