I have a list of points, and want to add a Bezier-spline using these points.
Following is my code:
import bpy name = "MyCurve" numPoints = 4 points = [ [1,1,1], [-1,1,1], [-1,-1,1], [1,-1,-1] ] curvedata = bpy.data.curves.new(name=name,type='CURVE') curvedata.dimensions = '3D' curvedata.fill_mode = 'FULL' curvedata.bevel_depth = 0.045 ob = bpy.data.objects.new(name+"Obj", curvedata) bpy.context.scene.objects.link(ob) polyline = curvedata.splines.new('BEZIER') polyline.bezier_points.add(numPoints) for num in range(numPoints): polyline.bezier_points[num].co = points[num] polyline.resolution_u = 1 print( len(polyline.bezier_points))
Now my problem is, that this code adds another point. The printed value will be
5 not as I expected
4. The added point is after the other points and is the point
(0, 0, 0). This is unwanted behavior.
What is wrong with my code?
My Blender version is 2.70 built 2014-03-19.