0

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.

Mr.Ruddy
  • 97
  • 1
  • 6
  • 1
    tldr: obj.animation_data.action.fcurves[i].keyframe_points[j].co The answer to your question is also in https://blender.stackexchange.com/questions/64447/how-do-i-add-keyframes-to-a-newly-created-action-with-no-associated-objects – Mutant Bob Sep 25 '17 at 17:29
  • See also https://blender.stackexchange.com/questions/23927/how-to-move-keyframes-using-python/23928 – Mutant Bob Sep 25 '17 at 17:34
  • 1
    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. – batFINGER Sep 25 '17 at 17:40
  • @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? – Mr.Ruddy Sep 25 '17 at 20:19
  • 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. – batFINGER Sep 30 '17 at 19:37

0 Answers0