I'm just trying to make a closed curve using just python for a script that I'm writing. This is what I have so far:
curveData = bpy.data.curves.new('myCurve', type='CURVE')
curveData.dimensions = '3D'
coords = [(0,0,0), (2,0,0), (2,-1,0), (0,-1,0)]
polyline = curveData.splines.new('POLY')
polyline.points.add(len(coords)-1)
for i, coord in enumerate(coords):
x,y,z = coord
polyline.points[i].co = (x, y, z, 1)
# create Object
curveOB = bpy.data.objects.new('myCurve', curveData)
# attach to scene and validate context
view_layer = bpy.context.view_layer
curveOB = bpy.data.objects.new('myCurve', curveData)
view_layer.active_layer_collection.collection.objects.link(curveOB)
Just need a way to connect the first and the last point. Please note the solution should work with bezier curves as well not just polyline curves. Because ultimately I'm trying to make a closed bezier curve, this is just for an example.
