How to prevent bevel shape rotation in extrusion operations?
I would like the final shape to remain "parallel" to the XY plane.
At the end of the extrusion (Due to the change of Z along the path) my profile shape has rotated:

Here is my code
def create_rectangular_curve(objname, lenX, lenY):
# create the Curve and the spline
ratioY=lenY/lenX
mycurve = bpy.data.curves.new(objname, type='CURVE')
mycurve.dimensions = '2D'
spline = mycurve.splines.new(type='POLY')
#add points to the spline
spline.points.add(4)
spline.points[0].co=(-lenX/2,-lenY/2,0,1)
spline.points[1].co=(lenX/2,-lenY/2,0,1)
spline.points[2].co=(lenX/2,lenY/2,0,1)
spline.points[3].co=(-lenX/2,lenY/2,0,1)
spline.points[4].co=(-lenX/2,-lenY/2,0,1)
#create Object
myobject = bpy.data.objects.new(objname, mycurve)
bpy.context.scene.collection.objects.link(myobject)
return myobject
def create_saw_curve(objname, nbPeriode, sizeX, sizeY):
# create the curve and the spline
ratioY=sizeY/sizeX
mycurve = bpy.data.curves.new(objname, type='CURVE')
mycurve.dimensions = '3D'
spline = mycurve.splines.new(type='BEZIER')
#add points to the spline
spline.bezier_points.add(nbPeriode4)
#the first one
spline.bezier_points[0].co=(0,0,-1)
spline.bezier_points[0].handle_left =(-1,-ratioY,-1)
spline.bezier_points[0].handle_right =(1,ratioY,-1)
#the others points
for i in range(1, nbPeriode4,4):
spline.bezier_points[i].co=(isizeX,sizeY,0)
spline.bezier_points[i].handle_left =(isizeX-1,sizeY-ratioY,0)
spline.bezier_points[i].handle_right =(isizeX+1,sizeY-ratioY,0)
spline.bezier_points[i+1].co=((i+1)sizeX,0,1)
spline.bezier_points[i+1].handle_left =((i+1)sizeX-1,ratioY,1)
spline.bezier_points[i+1].handle_right =((i+1)sizeX+1,-ratioY,1)
spline.bezier_points[i+2].co=((i+2)sizeX,-sizeY,0)
spline.bezier_points[i+2].handle_left =((i+2)sizeX-1,-sizeY+ratioY,0)
spline.bezier_points[i+2].handle_right =((i+2)sizeX+1,-sizeY+ratioY,0)
spline.bezier_points[i+3].co=((i+3)sizeX,0,-1)
spline.bezier_points[i+3].handle_left =((i+3)sizeX-1,-ratioY,-1)
spline.bezier_points[i+3].handle_right =((i+3)sizeX+1,ratioY,-1)
#create Object
myobject = bpy.data.objects.new(objname, mycurve)
bpy.context.scene.collection.objects.link(myobject)
return myobject
profileObject = create_rectangular_curve("profil", 4, 2)
curveObject = create_saw_curve('saw_curve',2,10,20)
curveObject.data.bevel_object = profileObject
curveObject.data.use_fill_caps = True
curveObject.data.bevel_mode = 'OBJECT'
curveObject.data.twist_mode = 'Z_UP'– Gorgious May 27 '21 at 22:03