0
$\begingroup$

Hey guys I've been trying to get a script going for Proportional moving of keyframes to set values on a given frame (to help correct captured data).

I've got an action in my scene I've started poking around at, but setting the value via script doesn't work with proportional on. Is there a different method I should be using?

import bpy
scene = bpy.context.window.scene

startFrame = scene.frame_start
endFrame = scene.frame_end

scene.tool_settings.use_proportional_fcurve = True
scene.tool_settings.proportional_size = 45 

# Get a list of actions from the Blend file.
actions = bpy.data.actions                  
for action in actions:
    my_action = action.name
    print(action.name)
# For each action get the Curve Groups.    
    act_curve = bpy.data.actions[action.name].groups 
    for curve in act_curve:
        print("curves", curve.name)

# using the actions above.
action = bpy.data.actions[my_action]
for fcu in action.fcurves:
    print(fcu.data_path + " channel " + str(fcu.array_index))
    for keyframe in fcu.keyframe_points:
        print(keyframe.co) #coordinates x,y

# moving the last keyframe to a given value.
bpy.data.actions[my_action].fcurves[0].keyframe_points[-1].co.y = 0
$\endgroup$
  • $\begingroup$ Seems I need to be using the correct area type. So change to the graph editor and then use transform.translate. workArea = bpy.context.area.type bpy.context.area.type = 'GRAPH_EDITOR' bpy.ops.transform.translate(value=(0, -10, 0), use_proportional_edit=True) bpy.context.area.type = workArea I want to pin the start and end keys to 0 (with a proportional value) to smooth the adjustment. I think this will work if I select the correct key, make a note of it's y pos/value and then translate it in Y by the opposite value. Does this sound like the right approach? $\endgroup$ – Mal Reed Nov 17 at 11:05

Your Answer

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

Browse other questions tagged or ask your own question.