From fe97b229d9970298a71a8bc083a312362c0f194e Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Thu, 27 Nov 2025 13:10:56 -0800 Subject: [PATCH] Channel bags now being created using the `anim_utils` convenience function --- io_scene_psk_psa/psa/importer.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/io_scene_psk_psa/psa/importer.py b/io_scene_psk_psa/psa/importer.py index 616a285..40db257 100644 --- a/io_scene_psk_psa/psa/importer.py +++ b/io_scene_psk_psa/psa/importer.py @@ -5,6 +5,7 @@ import numpy as np import re from bpy.types import Armature, Context, FCurve, Object, Bone, PoseBone from mathutils import Vector, Quaternion +from bpy_extras import anim_utils from .config import PsaConfig, REMOVE_TRACK_LOCATION, REMOVE_TRACK_ROTATION from .reader import PsaReader @@ -298,23 +299,8 @@ def import_psa(context: Context, psa_reader: PsaReader, armature_object: Object, case _: assert False, f'Invalid FPS source: {options.fps_source}' - if options.should_write_keyframes: - # Remove existing f-curves. - 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] - + if options.should_write_keyframes: + channelbag = anim_utils.action_ensure_channelbag_for_slot(action, action_slot) channelbag.fcurves.clear() # Create f-curves for the rotation and location of each bone.