I have some code that generates a curve:
import bpy
curve_data = bpy.data.curves.new("SimpleCurve", type='CURVE')
spline = curve_data.splines.new(type='POLY')
spline.points.add(3)
coords = [(0, 0, 0, 1), (1, 0, 0, 1), (1, 1, 1, 1), (0, 1, 1, 1)]
for i, co in enumerate(coords):
spline.points[i].co = co
curve_obj = bpy.data.objects.new("SimpleCurve", curve_data)
bpy.context.collection.objects.link(curve_obj)
This works fine, but when I edit the generated curve, dragging any point causes all points to reset their Z values to zero. What am I doing wrong?

