I am new to Blender. I need to spin a curve around the z-axis to create an arbitrary surface as shown below: enter image description here

enter image description here

I have successfully implemented spinning using bmesh. It seems I have to create an object possessing mesh as defined in bmesh. Is there any other way to do this spinning process using python script? My current code to generate curve is similar to [Ref]. Thank you.

EDIT1: If anyone can do this without using screw? Or how to use screw modifier to spin around an arbitrary axis in python script?


1 Answer 1


Screw the curve too.

Similarly to creating with bmesh

enter image description here

import bpy

def poly(x):
    return   0.2 * x * x - x + 3

cu = bpy.data.curves.new("poly", 'CURVE')
cu.dimensions  = '3D'
bez = cu.splines.new('BEZIER')
pts = [(poly(z), 0, z) for z in range(10)]
flat = [p for pt in pts for p in pt]
s = cu.splines.new('BEZIER')
s.bezier_points.add(len(pts) - 1)
# set the points in one fell swoop
s.bezier_points.foreach_set("co", flat)
# doesn't seem to work for handles so set them in loop
for bp in s.bezier_points:
    bp.handle_left_type = bp.handle_right_type = 'AUTO'

# lazy way to add curve object
ob = bpy.context.object
ob.data = cu

# default screw modifier spins 360 on z
screw = ob.modifiers.new("Screw", 'SCREW')
  • $\begingroup$ LOL. Thank you so much! It took me much time to figure out how to convert bmesh into an object. $\endgroup$
    – HSChan
    Commented Jul 18, 2018 at 20:13

You must log in to answer this question.

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