有没有办法在 Blender 中使用 python 脚本来 copy/paste 动作关键帧?

Is there a way to copy/paste action-keyframes with python script in Blender?

我有很多混合文件,每个文件都有很多动画(动作)。 我需要将所有动作的所有关键帧移动 15 帧,我可以使用(对于许多文件在 powershell 的帮助下):

    for action in bpy.data.actions: 
        for fcurve in action.fcurves:
            for point in fcurve.keyframe_points:
                point.co.x += 15.0

在脚本之前

脚本之后

这确实有效,问题是我需要将它们导出为 fbx, 所以在导出动画时它会忽略前 14 帧,因为它们是空的。我需要的是 copy/paste 或将第 15 帧复制到第 0 帧,以在开始时获得静态动画(我将使用它在动画之间淡入淡出)。

这就是我想要的结果:

您可以insert a new keyframe point将帧设为 1 并使用第一个关键帧的值。

for action in bpy.data.actions:
    for fcurve in action.fcurves:
        fcurve.keyframe_points.insert(1, fcurve.keyframe_points[0].co.y)

如果要复制或设置其他属性,插入returns新的keyframe