Python nurbCrv

I have no idea what that is! pwk? :wink:

Starting from what we had above, you could do the following to alter the control point weights:

import Rhino.Geometry as rg
import random

# Create an interpolated curve
curve = rg.Curve.CreateInterpolatedCurve(points, 3) # 3 = degree
# Make it rational which means that it has weighted control points
curve.Points.MakeRational()
print curve.IsRational

# Randomly change the weights
control_points = []
for i in range(curve.Points.Count): # loop through the control points by index
    curve.Points.SetWeight(i, random.random()) # set a random weight for the control point at index i
    control_points.append(curve.Points[i].Location) # optional

You have to tag me or reply to one of my answers directly, otherwise I wonโ€™t be notified, if you post something that Iโ€™m concerned with.

Anyways, the randomization produces quite funky results. :wink:

1 Like