I want to create a curve with 4 points in python. So i figured that I could subdivide a primitive curve twice and delete one of the points. The code below kinda works by selecting a single point and deleting it. Well, except that by default all points are selected so this simply deletes all the points. I suppose that I can loops through all the points and handles and deselect that way. But you can deselect everything by a single mouseclick (or a single command in object mode), so isn't there a easier/more elegant way to do this?
bpy.ops.curve.primitive_bezier_curve_add(enter_editmode=False, align='WORLD')
my_curve= bpy.context.active_object
bpy.ops.object.editmode_toggle()
bpy.ops.curve.subdivide()
bpy.ops.curve.subdivide()
my_curve.data.splines[0].bezier_points[3].select_control_point = True
bpy.ops.curve.delete(type='VERT')
bpy.ops.object.editmode_toggle()
number_cuts = 2
. ? $\endgroup$ – batFINGER Dec 3 '20 at 14:03