# How do I draw a parametric column or cylinder with varying radius using python

I am new to Blender. I have been wondering how to draw a parametric column or cylinder with varying radius using a python script. The radius is a function of cylinder height (polynomial function). Could anyone provide examples for me to look at? Thank you.

I also wonder if the add_mesh_3d_function_surface.py will help. Thanks.

Using bmesh and screw

Make a simple bmesh edge on zx plane using poly function, then spin it around the z axis. I've added a screw modifier to do the spinning, and commented out the bmesh spin operator.

import bpy
import bmesh

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

bm = bmesh.new()

# draw on zx plane
v0 = bm.verts.new((poly(0), 0, 0))
for dz in range(1, 100):
z = dz / 50
v = bm.verts.new((poly(z), 0, z))
edge = bm.edges.new((v0, v))
v0 = v