Convert rhinosctiptsyntax GUID to Rhino.Geometry.Curve

I have a curve picked in the Rhino environment in a script, returning it’s GUID using rs.GetCurveObject() [0]. But I want to perform:

crv_t = crv.ExtremeParameters(dir)

where crv is the object I have a GUID for stored in a variable, using the Y and/or X axis.

Would it be the ‘opposite’ of Rhino.Geometry.Curve.ToString. ?

This might cause my script to fall down since certain parts already rely on one way of thinking, and then when I’m limited and need something like ExtremeParameters I’m now snookered.

Thank you!

EDIT: Okay so I found it was just rs.coercecurve(curve-guid) to do this - can anybody enlighten me as to why the oerce functions don’t have documentation or anything? And any hints or best practices for going back and forth in this way?

Hi @Jonathan_Hutchinson, if you need all in one single variable, work with Rhino objects:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    # prompt 
    crv_id = rs.GetObject("Curve", rs.filter.curve, preselect=True, select=False)
    if not crv_id: return
    # get the rhino object from the id
    crv_obj = rs.coercerhinoobject(crv_id)
    print "crv_obj = {}".format(crv_obj)
    # a rhino object stores it's unique id too 
    print "crv_id = {}".format(crv_obj.Id)
    # an object has a geometry property 
    crv = crv_obj.Geometry
    print "crv = {}".format(crv)


1 Like

That’s really helpful - thank you @clement .