# How to Add driver to modifier SimpleDeform-angle by scipt python in blender 2.8

I create script , that script add object, now i create, a modifier , and i want to simulate “Swinging” but i can not understand how it can be done,does anyone know how I can do? :

bend = object.modifiers.new(name="bend", type='SIMPLE_DEFORM')
bend.deform_method = 'BEND'
###noob example:


Consult docs or other questions on how to add a driver

Here is your "noob" code edited to add a driver. Select a mesh object and run script.

It so happens that the current context.scene.frame_current is known to the driver namespace as frame so no driver variable need be created.

import bpy
ob = bpy.context.object
bend = ob.modifiers.new(name="bend", type='SIMPLE_DEFORM')
bend.deform_method = 'BEND'


Also remember that angles when scripting are natively in radians. 2 pi radians = 360 degrees. So at frame 20 the angle of bend will be sine of 1 radian (or around 57 degrees.) Use sin(radians(frame) / 20) if frame is expected as degrees.
• bend.angle or getattr(bend, "angle") From the driver try fcurve.evaluate(frame) but not sure if this will work as expected. – batFINGER Mar 7 '19 at 11:42