How to use the rhino3dm.NurbsCurve function in rhino3dm

To help you get started, we’ve selected a few rhino3dm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jesterKing / import_3dm / import_3dm / converters / curve.py View on Github external
nurbs = bcurve.splines.new('NURBS')
    nurbs.use_cyclic_u = rcurve.IsClosed

    nurbs.points.add(N - 1)
    for i in range(0, N):
        rpt = rcurve.Points[i]
        nurbs.points[i].co = (rpt.X * scale, rpt.Y * scale, rpt.Z * scale, rpt.W * scale)

    #nurbs.use_bezier_u = True
    nurbs.use_endpoint_u = True
    nurbs.order_u = rcurve.Order
            
    return nurbs

CONVERT[r3d.NurbsCurve] = import_nurbs_curve

def import_arc(rcurve, bcurve, scale):

    spt = Vector((rcurve.Arc.StartPoint.X, rcurve.Arc.StartPoint.Y, rcurve.Arc.StartPoint.Z)) * scale
    ept = Vector((rcurve.Arc.EndPoint.X, rcurve.Arc.EndPoint.Y, rcurve.Arc.EndPoint.Z)) * scale
    cpt = Vector((rcurve.Arc.Center.X, rcurve.Arc.Center.Y, rcurve.Arc.Center.Z)) * scale

    r1 = spt - cpt
    r2 = ept - cpt

    r1.normalize()
    r2.normalize()

    d = rcurve.Arc.Length * scale

    normal = r1.cross(r2)