0

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()

This is what I get prior to the delete command

DrDress
  • 563
  • 4
  • 19
  • Actually the looping works fine and isn't so cumbersome. But I'm still interested in a better understanding of manipulating curves, so any answer to my question would still be valued. – DrDress Dec 03 '20 at 10:13
  • 2
    What really is the question here?. To create a spline from points would not go anywhere using code above Dupe of intention: https://blender.stackexchange.com/questions/120074/how-to-make-a-curve-path-from-scratch-given-a-list-of-x-y-z-points . https://blender.stackexchange.com/questions/180148/create-curve-from-numpy-array-using-python – batFINGER Dec 03 '20 at 11:22
  • 2
    https://blender.stackexchange.com/questions/110177/connecting-two-points-with-a-line-curve-via-python-script https://blender.stackexchange.com/questions/127603/how-to-specify-nurbs-path-vertices-in-python – batFINGER Dec 03 '20 at 12:00
  • Thanks for insightfull feedback. I didn't state clearly that I had to use subdivide when I create the curve and then remove unwanted points – DrDress Dec 03 '20 at 12:49
  • 2
    It's becoming clearer. To clarify further is it also a requirement to subdivide twice instead of once with number_cuts = 2. ? – batFINGER Dec 03 '20 at 14:03
  • number of cuts?! I didn't know that one. I think that is a lot more what I need. Thanks! – DrDress Dec 04 '20 at 08:02

0 Answers0