How to add a Rhino.Geometry.BezierCurve in RinhoPyton Editor

Hi I am new in the rhino script environment.
Trying some code in the RinhoPyton Editor, start reading points from a CSV
and drawing some curves.

I have ReadPointsDef that return a Rhino.Collections.Point3dList()

points = ReadPointsDef(“point.csv”)

Then I add some objects:


    interCurve = rs.AddInterpCurve(points,3,4) 
    rs.ObjectColor(interCurve, [255,0,0])#red
    #-----------------------------
    curve= rs.AddCurve(points) 
    rs.ObjectColor(curve, [0,0,255])#blue
    #-----------------------------
    beCurve = Rhino.Geometry.BezierCurve(points)       
    Rhino.Add(beCurve)  ---> this does not Work
    Rhino.RhinoDoc.Objects.Add(beCurve) ---> this does not Work
   
AddInterpCurve and     AddCurve work perfect, but I can´t Add a Rhino.Geometry,

How must to proceed ?

If you look in the debugger, is beCurve actually succeeding (you get something)?
If so does scriptcontext.doc.Objects.AddCurve(beCurve) work? (you need to import scriptcontext)

–Mitch

A Rhino.Geometry.BezierCurve is a special type of curve, used primarily for low level calculations. You cannot add one to a Rhino document because the class does not inherit from Rhino.Geometry.Curve. But, you can convert a Rhino.Geometry.BezierCurve to a Rhino.Geometry.NurbsCurve using Rhino.Geometry.BezierCurve.ToNurbsCurve(). You can then add the resulting NURBS curve to a document.

Thanks guys.

I resolve:

myBezierCurve = Rhino.Geometry.BezierCurve(points)  
scriptcontext.doc.Objects.AddCurve(myBezierCurve.ToNurbsCurve()) 

Of course, the alternative is to just create a NURBS curve from the get go:

# Construct a control-point curve
crv0 = Rhino.Geometry.NurbsCurve.CreateControlPointCurve(points)
# or, construct an interpolated curve
crv1 = Rhino.Geometry.NurbsCurve.CreateInterpolatedCurve(points)
1 Like