Channel bags now being created using the anim_utils convenience function

This commit is contained in:
Colin Basnett
2025-11-27 13:10:56 -08:00
parent 622aa46a82
commit fe97b229d9

View File

@@ -5,6 +5,7 @@ import numpy as np
import re import re
from bpy.types import Armature, Context, FCurve, Object, Bone, PoseBone from bpy.types import Armature, Context, FCurve, Object, Bone, PoseBone
from mathutils import Vector, Quaternion from mathutils import Vector, Quaternion
from bpy_extras import anim_utils
from .config import PsaConfig, REMOVE_TRACK_LOCATION, REMOVE_TRACK_ROTATION from .config import PsaConfig, REMOVE_TRACK_LOCATION, REMOVE_TRACK_ROTATION
from .reader import PsaReader from .reader import PsaReader
@@ -298,23 +299,8 @@ def import_psa(context: Context, psa_reader: PsaReader, armature_object: Object,
case _: case _:
assert False, f'Invalid FPS source: {options.fps_source}' assert False, f'Invalid FPS source: {options.fps_source}'
if options.should_write_keyframes: if options.should_write_keyframes:
# Remove existing f-curves. channelbag = anim_utils.action_ensure_channelbag_for_slot(action, action_slot)
if len(action.layers) == 0:
layer = action.layers.new(armature_object.name)
else:
layer = action.layers[0]
if len(layer.strips) == 0:
action_strip = layer.strips.new()
else:
action_strip = layer.strips[0]
if len(action_strip.channelbags) == 0:
channelbag = action_strip.channelbags.new(action_slot)
else:
channelbag = action_strip.channelbags[0]
channelbag.fcurves.clear() channelbag.fcurves.clear()
# Create f-curves for the rotation and location of each bone. # Create f-curves for the rotation and location of each bone.