Bend an object by only moving one face vertices ?


I would really appreciate if someone helps me how to figure this one out.

I have a cylinder bar, and I can make it move around some coordinates (code below) … however I would like the bar to bend while moving … meaning the corner vertices should not move and stay fixed, while center vertices should move … thus looking like bar is bent, where its corners are fixed.

Can anyone please help me in this regard ? …


import bpy
bpy.ops.mesh.primitive_cylinder_add(vertices=12, radius=0.01, depth=6, location=posd) 
obj3 = bpy.context.active_object  
pos = [(float(dx), float(dy)] # coordinates saved as array in pos[0] and pos[1]
frame_num = 0  
for pos in pos:  
    bpy.context.scene.frame_set(frame_num) = obj3 = True
    bpy.context.active_object.location = (1000*pos[0],1000*pos[1],0)
    bpy.ops.anim.keyframe_insert(type='Location', confirm_success=True)  
    frame_num += 1