0
$\begingroup$

I've been attempting to set a keyframe for the Bevel Factor Start and End of a Curve.

I've tried using

bpy.ops.anim.keyframe_insert_button(
        'Curve.bevel_factor_start', 
         index=-1, 
         frame=bpy.context.scene.frame_current, 
         group="")

But I really don't know where to go from here. Pressing "I" works just fine but I can't find the right command in the API to control this property

$\endgroup$
1
  • $\begingroup$ As an addendum to Ratt's answer: By blenders naming convention, if a name starts with a capital it is a class. in this case. bpy.types.Curve A curve objects data part is an instance of type Curve. $\endgroup$ – batFINGER Jan 31 '19 at 20:18
1
$\begingroup$

While likely not optimized the following appears to work both in blender 2.79b official and the 2.80 beta build I have at the moment and may assist in how to handle adding the key frames and manipulating them afterwards.

import bpy

obj = bpy.context.active_object  # Your pre-existing selected curve


def add_keyframes(obj):
    if obj.data.bevel_object:  # verify bevel object already selected
        obj.data.keyframe_insert(
                "bevel_factor_start",
                index=-1,
#                frame=1,  # defaults to current frame
#                group=""
                )
        obj.data.keyframe_insert(
                "bevel_factor_end",
                index=-1,
#                frame=1,  # defaults to current frame
#                group=""
                )

add_keyframes(obj)


def mod_fcurve(obj, path):
    for fc in obj.data.animation_data.action.fcurves:
        if fc.data_path == path:
            my_fc = fc
    for pt in my_fc.keyframe_points:
        pt.co.x += 1  # increase x 'frame number' of points
        pt.co.y += 0.1  # increase y 'value' of all pts in curve


mod_fcurve(obj, "bevel_factor_start")
$\endgroup$
0
$\begingroup$

Figured it out, this is what I was trying to achieve

bpy.context.object.data.bevel_factor_start = 0 #set factor to 0 bpy.context.object.data.keyframe_insert(data_path='bevel_factor_start') #keyframe it

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.