I am trying to create a bezier curve in Python with 3 control points, P1, P2 and P3 (lines 47 to 58). Somehow I keep getting an extra extension (from P3 to the origin). How do I avoid this from happening? enter image description here

  • $\begingroup$ Please paste your code in text format (wrapped in triple backticks or indented so it's formatted as a codeblock) $\endgroup$ Commented Jun 28, 2023 at 17:27

1 Answer 1


The problem is that the new spline you create on line 42 already has one point at the origin and to this one point you then add 10 more on line 45. So you end up with 11 points. Then you move the points 0 to 2 to the coordinates but the rest is left on the origin. So to solve this just add 2 points, not 10.

import bpy
curve = bpy.data.curves.new("curve", "CURVE") #create curve
spline = curve.splines.new("BEZIER") # create spline in curve with 1 point
obj = bpy.data.objects.new("MyCurve", curve) # create object with curve in it
scene = bpy.context.scene
scene.collection.objects.link(obj) #link object to scene

spline.bezier_points.add(2) #add two points so we got 3 
#create a point list
P = [[0, 1, 0],
    [0.7, 0.5, 0],
    [1, 0, 0]]

#itterate over the list of coordinates and assign to spline. 
# ! len(P) must be equal len(spline.bezier_points)
for i in range(len(P)):
    spline.bezier_points[i].co = P[i]
    spline.bezier_points[i].handle_left_type = "AUTO"
    spline.bezier_points[i].handle_right_type = "AUTO"

Hope this helps.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .