Not much love for curve weight in R6


(Lukasz Domagala) #1

This works just fine in R5
Create curve, adjust weight of control points and try to split this curve with point…no? OK let’s try something different.
Extrude this curve and split the edge of this surface…So far so good. Try to blend surface from two edges we just created…interesting isn’t it?


curve_weight_issue.3dm (81.0 KB)

Side question:
How to construct a curve in RhinoCommon from a list of points,weights and knots? I looked up API documentation but couldn’t find anything.
Asking because I have a gh curve connected to control points component which gives you P,W,K…I want to modify Weights and construct a new curve.


#2

http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_NurbsCurve__ctor_1.htm

You have to add the weights separately… rhinoscriptsyntax AddNurbsCurve()

def AddNurbsCurve(points, knots, degree, weights=None):
    """Adds a NURBS curve object to the document
    Parameters:
      points = list containing 3D control points
      knots = Knot values for the curve. The number of elements in knots must
          equal the number of elements in points plus degree minus 1
      degree = degree of the curve. must be greater than of equal to 1
      weights[opt] = weight values for the curve. Number of elements should
          equal the number of elements in points. Values must be greater than 0
    """
    points = rhutil.coerce3dpointlist(points, True)
    cvcount = len(points)
    knotcount = cvcount + degree - 1
    if len(knots)!=knotcount:
        raise Exception("Number of elements in knots must equal the number of elements in points plus degree minus 1")
    if weights and len(weights)!=cvcount:
        raise Exception("Number of elements in weights should equal the number of elements in points")
    rational = (weights!=None)
    
    nc = Rhino.Geometry.NurbsCurve(3,rational,degree+1,cvcount)
    for i in xrange(cvcount):
        cp = Rhino.Geometry.ControlPoint()
        cp.Location = points[i]
        if weights: 
            cp.Weight = weights[i]
        else:
            cp.Weight = 1.0
        nc.Points[i] = cp
    for i in xrange(knotcount): nc.Knots[i] = knots[i]
    rc = scriptcontext.doc.Objects.AddCurve(nc)
    if rc==System.Guid.Empty: raise Exception("Unable to add curve to document")
    scriptcontext.doc.Views.Redraw()
    return rc

C#: Reconstructing a NURBS Curve from another NURBS Curve's Properties?
(Lukasz Domagala) #3

Oh you’re right…I didn’t realize I could add weight separately…thank you Mitch