I have over 1000 animation files that I want to "crop" off keyframes outside of a specified range.
Keyframes all start at frame 1 instead of frame 0, as such I want to shift all keyframes by one frame such that the animations start at frame 0.
I have an int variable named "framelength" which stores the framenumber of the last good frame. I want to remove every keyframe after this value.
The most similar code I was able to find online was:
How to remove all only rotation keyframes from current action with Python? and Editing fcurve.keyframe points in FAST mode? Both were written by BatFINGER.
I tried using a combination of the two to achieve what I want, but am struggling with deleting only certain keyframes.
ob = context.object
ad = ob.animation_data
action = ad.action if ad else None
if action:
for fc in action.fcurves:
sel = list(bool(i > int(framelength)) for i in range(len(fc.keyframe_points)))
for i in range(len(fc.keyframe_points)):
if i>35:
fc.pop()
Above is my attempt at solving the problem.
_kfs[:,0] -= start_frame
. For when use shift is set. blender.stackexchange.com/a/214899/15543 $\endgroup$