0
$\begingroup$

I'm trying to write a script that would iterate over all keyframes on the selected armature and then advance the timeline to compare the previous keyframe to the current to see if it's identical. If it stays identical throughout the entire timeline let's say 1-240 frames then it should delete the entire keyframe row/action.

My main issue is that I'm not sure on how to access the keyframe data or fcurve data to then later do a comparison between the current frame and the previous.

$\endgroup$
5
  • 1
    $\begingroup$ tldr: obj.animation_data.action.fcurves[i].keyframe_points[j].co The answer to your question is also in blender.stackexchange.com/questions/64447/… $\endgroup$
    – Mutant Bob
    Commented Sep 25, 2017 at 17:29
  • $\begingroup$ See also blender.stackexchange.com/questions/23927/… $\endgroup$
    – Mutant Bob
    Commented Sep 25, 2017 at 17:34
  • 1
    $\begingroup$ Suggest looking at bpy.ops.graph.clean() and bpy.ops.graph.smooth() These can be run from graph editor by selecting curves and choosing smooth or clean from Keys menu, to see if they give desired result. $\endgroup$
    – batFINGER
    Commented Sep 25, 2017 at 17:40
  • $\begingroup$ @batFINGER the graph.clean() sorta did the trick. It removed alot of identical keyframes. However it removes every keyframe except for the first keyframe so now I'm left with alot of empty channels with only one keyframe in each. Is there a quick way to delete the last remaining key aswell? $\endgroup$
    – Mr.Ruddy
    Commented Sep 25, 2017 at 20:19
  • $\begingroup$ Remember if you remove all keyframes, the action may become unpredictable when changed, used in NLA etc, as the unkeyed items will retain whatever value was last set. If you really want to remove last one, edit question with how you want it to work and I'll (or someone else) will answer. $\endgroup$
    – batFINGER
    Commented Sep 30, 2017 at 19:37

0

You must log in to answer this question.

Browse other questions tagged .