# Adding points to curve with bpy

I want to create a curve between two given points. But I don't know how to add the points to the curve object. When you create a new mesh data block, you have the from_pydata() function to add verts, but I can't find an equivalent for the cruve data block. This is my code so far (just creating a new cruve data block and a curve object, then linking it to the collection)

def createCurve():
star_point = [0,0,0]
end_point = [1,0,0]
curve = bpy.data.curves.new(name='curve_data',type='CURVE')
curveObj = theObj = bpy.data.objects.new("curve_obj", curve)


Can someone help me?

• you want to select the segment between the two points and then subdivide the segment with the the subdivide operator Jan 28 at 15:03

polyline = curve.splines.new('POLY')