I would like to script keyframes for bevel modifier width (and many more later). Here is what I have so far. I've commented out the last line which doesn't work. When I type help(ao.keyframe_insert)
, I get :arg data_path: path to the property to key, analogous to the fcurve's data path.
but that doesn't help me since I haven't use fcurves yet.
The first half of my question is "how to key the bevel width as I am trying in the example script?"
...and the second half is "where could I have looked this up?" or "how can I know in general what do write in keyframe_insert(data_path=""
without asking a new question each time I want to key something?"
Thanks for your understanding!
import bpy
import numpy as np
frame_a, frame_b = 25, 35
sigma_a, sigma_b = 7, 10
n_frames = 60
if 1 == 1:
bpy.ops.mesh.primitive_cube_add(radius=1, location=(0.0, 0.0, 2.0))
bpy.ops.object.modifier_add(type='BEVEL')
bpy.context.object.modifiers["Bevel"].width = 0.3
bpy.context.object.modifiers["Bevel"].segments = 3
ao = bpy.context.active_object
bpy.context.scene.frame_end = n_frames
for i_frame in range(n_frames):
a = np.exp(-(i_frame - frame_a)**2 / (2.*sigma_a**2))
s = 1.0 + 0.3 * a
bw = 1.0 * a
ao.modifiers["Bevel"].width = bw
ao.scale = (s, s, s)
ao.keyframe_insert(data_path="scale", frame = i_frame + 1, index=-1)
#ao.keyframe_insert(data_path="modifiers['Bevel'].width", frame = i_frame + 1, index=-1)