Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. import bpy
  2. import bmesh
  3. from math import radians
  4.  
  5. def poly(x):
  6. return 0.2 * x * x - x + 3
  7.  
  8. cu = bpy.data.curves.new("poly", 'CURVE')
  9. cu.dimensions = '3D'
  10. bez = cu.splines.new('BEZIER')
  11. pts = [(poly(z), 0, z) for z in range(10)]
  12. flat = [p for pt in pts for p in pt]
  13. s = cu.splines.new('BEZIER')
  14. s.bezier_points.add(len(pts) - 1)
  15. # set the points in one fell swoop
  16. s.bezier_points.foreach_set("co", flat)
  17. # doesn't seem to work for handles so set them in loop
  18. for bp in s.bezier_points:
  19. bp.handle_left_type = bp.handle_right_type = 'AUTO'
  20.  
  21. # lazy way to add curve object
  22. bpy.ops.curve.primitive_bezier_curve_add()
  23. ob = bpy.context.object
  24. ob.data = cu
  25.  
  26. # default screw modifier spins 360 on z
  27. screw = ob.modifiers.new("Screw", 'SCREW')
Add Comment
Please, Sign In to add comment