[GhPython] Convert PolyCurve to GUID?

I can’t find a way to convert a polycurve into a guid. I want to use rs.SimplifyCurve() on a polycurve but the error says it couldn’t be converted to guid. Is it impossible to convert polylines to guids? Is there any way around this?

(rs.coerceguid(polycurve) returns NoneType: )
PolyCurvesToGUID

Hi @joshuaterranova01,

You cannot convert a curve to a GUID. But if you add the curve to the document, the newly added curve object will be assigned a GUID, which you can then reference from rhinoscriptsyntax.

If that’s too much, then just use Curve.Simplify.

– Dale

You probably don’t need to convert it, check this out instead:

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_Simplify.htm

Thank you for the help! I’ll try the Simplify. For future reference, how would I add a curve in a python script to my document, thus assigning it a GUID?

Hi @joshuaterranova01,

If you like using rhinoscriptsyntax, then you can use one of the many "rs.Add` functions.

https://developer.rhino3d.com/api/RhinoScriptSyntax/#curve

Otherwise, just add it to the document’s object table using ObjectTable.AddCurve.

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc

...

sc.doc.Objects.AddCurve(pOffset)
sc.doc.Views.Redraw()