Can I add new a BezierSplinePoint to the start and end of a given curve in python. I'm thinking something like this:
curve = bpy.context.active_object # Some given curve with a disired shape
bpy.ops.object.editmode_toggle()
bpy.ops.curve.subdivide(number_cuts = N) # It now has +N point which DOESN'T alter the original shape. I need this.
The rest is only pseudo-code
start_point = BezierSplinePoint(start_coordinates?) # I don't know how to create custom points
end_point = BezierSplinePoint(start_coordinates?) # I don't know how to create custom points
curve.data.splines[0].bezier_points.add_point_at_index(start_point, index=0) # How to add thise point to the collection
curve.data.splines[0].bezier_points.add_point_at_index(end_point, index=N+1) # How to add thise point to the collection
EDIT: This post Poly / Bezier curve from a list of coordinates does pretty much what I want, but it starts the curve from scratch, where as I have most of the points already
EDIT2: This is driving me crazy! I figured that I could add points like so:
# curve is the object I try to manipulate
bp = curve.data.splines[0].bezier_points
bp.add(2)
and then loop over all the points and move their index up by one, and then set the two outer verteces with:
curve.data.splines[0].bezier_points[0].co = (1,2,3)
curve.data.splines[0].bezier_points[0].handle_right = (4,5,6)
curve.data.splines[0].bezier_points[0].handle_left = (7,8,9)
This is quite frustrating considering that python usually is very generous with regards to array and list manipulation. But I can't get this to work either! Aren't the points ordered in the collection like they are connected along the curve?