Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- import bmesh
- from math import radians
- 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
- bpy.ops.curve.primitive_bezier_curve_add()
- ob = bpy.context.object
- ob.data = cu
- # default screw modifier spins 360 on z
- screw = ob.modifiers.new("Screw", 'SCREW')
Add Comment
Please, Sign In to add comment