Hi All,
I found this code in the API.
At this page:
http://www.blender.org/documentation/244PythonDoc/Curve-module.html
def bezList2Curve(bezier_vecs):
def bezFromVecs(vecs):
bt= BezTriple.New(vecs[0].x, vecs[0].y, vecs[0].z, vecs[1].x, vecs[1].y, vecs[1].z, vecs[2].x, vecs[2].y, vecs[2].z)
bt.handleTypes= (BezTriple.HandleTypes.FREE, BezTriple.HandleTypes.FREE)
return bt
# Create the curve data with one point
cu= Curve.New()
cu.appendNurb(bezFromVecs(bezier_vecs[0])) # We must add with a point to start with
cu_nurb= cu[0] # Get the first curve just added in the CurveData
i= 1 # skip first vec triple because it was used to init the curve
while i<len(bezier_vecs):
bt_vec_triple= bezier_vecs<i>
bt= bezFromVecs(bt_vec_triple)
cu_nurb.append(bt)
i+=1
# Add the Curve into the scene
scn= Scene.GetCurrent()
ob = scn.objects.new(cu)
return ob
I am wondering how to use this function?
My goal is to generate a curve with three points in it.
Here is my code:
#Build a three point curve.
localCurvePoints = []
localCurvePoints.append(Vector(0,100,-100))
localCurvePoints.append(Vector(0,0,0))
localCurvePoints.append(Vector(0,100,100))
localCurveObj = bezList2Curve(localCurvePoints)
The code errors out in [I]bezList2Curve with “AttributeError: ‘float’ object has no attribute ‘x’”
So how do I populate my localCurvePoints array so it will work with this API function and generate a properly formed curve?
Thanks