zote
zote
Published on 2025-01-15 / 35 Visits
0
0

python: blender修改每个关键帧

修改每个关键帧的rotation X 为0°

在blender视口界面上方点击scripting

import bpy

# 获取当前场景
scene = bpy.context.scene

# 遍历所有的对象
for obj in scene.objects:
    # 仅处理具有动画数据的对象
    if obj.animation_data is not None and obj.animation_data.action is not None:
        fcurves = obj.animation_data.action.fcurves
        # 遍历对象的所有F-Curve
        for fcurve in fcurves:
            # 找到与旋转X相关的F-Curve
            if fcurve.data_path == "rotation_euler" and fcurve.array_index == 0:
                # 遍历所有关键帧并将值设为0
                for keyframe in fcurve.keyframe_points:
                    keyframe.co[1] = 0.0
                    keyframe.handle_left[1] = 0.0
                    keyframe.handle_right[1] = 0.0
                # 更新F-Curve以反映更改
                fcurve.update()


Comment