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.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)
  • $\begingroup$ just switch the double quotes and the single quotes in the last line 'modifiers["Bevel"].width' $\endgroup$
    – Chebhou
    Jul 27, 2015 at 5:35
  • $\begingroup$ Wow! @Chebhou that's just what I needed - thanks! I'm wondering now should I just delete the question (it's really a non-question almost). $\endgroup$
    – uhoh
    Jul 27, 2015 at 5:42
  • $\begingroup$ I'll try @zeffii. That's a good answer to link to. But I don't know what an "outliner" is. $\endgroup$
    – uhoh
    Jul 27, 2015 at 5:53
  • $\begingroup$ Aha! got it. But I don't see how one could find 'modifiers["Bevel"].width' by looking at the outliner. $\endgroup$
    – uhoh
    Jul 27, 2015 at 6:08
  • $\begingroup$ @uhoh you can find it from the UI not the outliner exactly $\endgroup$
    – Chebhou
    Jul 27, 2015 at 6:15

1 Answer 1


To get the data_path of a UI element (property, icon..), rightclick it and select "Copy Data Path"

enter image description here

Wrapping the resulting data_path with double quotes is a legal python string representation (eg: "modifiers['Bevel'].width"), and arguably should be allowed. But the parser of properties favours 'modifiers["Bevel"].width', presumably to keep the string parsing to a minimal implementation.

The above will be able to compute most kinds of data_path, but if it fails you can

  • make a keyframe for the property
  • go to the Outliner (set to view Datablocks)
  • navigate to Actions -> (Object/Scenename)+Action -> F-Curve
  • See Data Path. (this is what the initial

    path to the property to key, analogous to the fcurve's data path

    refers to.)

  • $\begingroup$ I see many good things I didn't know where there when I right click things like buttons, objects, or even sub-items in the outliner. But I never see "Copy data_path" I'm using 2.74 but do I need to turn something on? $\endgroup$
    – uhoh
    Jul 27, 2015 at 6:41
  • 1
    $\begingroup$ No, it's me. I just failed to click on things that were actually data. The image is extremely helpful! $\endgroup$
    – uhoh
    Jul 27, 2015 at 6:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .