Python in Grasshopper (Unable to Convert GUID to Curve)

Hi, I have a GhPython script component which I am inputting a Referenced Curve as a Type Hint (GUID) as an Item Access.

In the script, I wish to convert the GUID into a curve using rs.CurvePoints, however, it throws an error “Unable to convert into Curve geometry”

I have attached a screenshot of my grasshopper canvas + uploaded part of the code below. Any help would be greatly appreciated, im rather new to Python in GH.

Python code start:

import rhinoscriptsyntax as rs

class Chain():

def __init__(self, POLYLINE, STIFFNESS, RAD, MASS, MAXVEL, DAMPING):
    self.poly = POLYLINE
    self.stiff = STIFFNESS
    self.rad = RAD
    self.mass = MASS
    self.maxvel = MAXVEL
    self.damping = DAMPING
    self.vtxs = rs.CurvePoints(self.poly)
    self.nodes = []
    self.springs = []

… (removed some code)

Ch = Chain(P, S, R, M, V, D)

Code end

Assuming there really is a Curve (i.e. not a Line or a Point3D etc.) in the Param,
if it’s a reference to a rhino Curve, try setting sc.doc = Rhino.RhinoDoc.ActiveDoc* . Experiment with that and the typehint - try list and item access too.

*(after import Rhino and import scriptcontext as sc. Make sure it’s set back to sc.doc = ghdoc afterwards for anything else using Grasshopper geometry, it’s not just a global variable, it’s a module variable that’s shared between all the GHPython processes).

Referenced geometry can be difficult as the reference changes with every solution. But if nothing else works, try coercing the curve from the uuid using from sc.doc.Objects.FindGeometry

It looks like you’re missing a type hint:

python curve.gh (5.9 KB)