1
$\begingroup$

I have N objects in a scene and each has baked keyframes on some frame_start, frame_end interval.

Can anyone help me to write a script to scale keyframes for all of the objects along x axis and set interpolation type to constant. I cannot find an appropriate function to scale that programmatically.

thanks

$\endgroup$
2
  • $\begingroup$ Can I just ask, are you asking for a scripted solution because you specifically want to script it or because you don't know of a way to do it via the interface? $\endgroup$ Aug 8, 2014 at 16:06
  • $\begingroup$ Because i specifically want to script it. $\endgroup$ Aug 8, 2014 at 17:01

1 Answer 1

1
$\begingroup$

I found a solution, however it resizes keypoints around arbitrary point.

old_type = bpy.context.area.type
bpy.context.area.type = 'GRAPH_EDITOR'
bpy.ops.graph.interpolation_type(type='CONSTANT')
bpy.context.scene.frame_current = 1
bpy.ops.transform.resize(value=(6, 1, 1))
bpy.context.area.type = old_type
$\endgroup$
1
  • $\begingroup$ The arbitrary point will be the centre of the selected keyframes. This answer might interest you to get the first of the selected frames to the frame you want. $\endgroup$
    – sambler
    Aug 9, 2014 at 9:32

You must log in to answer this question.

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