I've looked a bit at Yorik's code in Draft module's BSpline class, and I think the bulk of what I need is in:
Code: Select all
def parameterization (self, pts, a, closed):
# Computes a knot Sequence for a set of points
# fac (0-1) : parameterization factor
# fac=0 -> Uniform / fac=0.5 -> Centripetal / fac=1.0 -> Chord-Length
if closed: # we need to add the first point as the end point
pts.append(pts[0])
params = [0]
for i in range(1,len(pts)):
p = pts[i].sub(pts[i-1])
pl = pow(p.Length,a)
params.append(params[-1] + pl)
return params
I got it once I found wmayer's [url = https://forum.freecadweb.org/viewtopic.php?t=741[/url]URL post :
Code: Select all
def CalculateSpline(points_list):
spline=Part.BSplineCurve()
points=[]
for i in points_list:
points.append(i)
spline.interpolate(points)
spline.toShape()
return spline