From 95c8521eb683a0b35aee9d1f36843cffd788a118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 23 Sep 2025 16:53:59 +0200 Subject: [PATCH] Refactor: convert "F-Curve path refactor" code to current Action API Convert the code in `scripts/modules/animsys_refactor.py` from the legacy Actions API to the current API. The code was made for very old rigs (2.70 and older, last updated for Caminandes in 2014). The updated code seems to work on a Caminandes test file, and produces the same logging on the terminal as in Blender 4.3 (before slotted Actions). No functional changes. This is part of #146586 Pull Request: https://projects.blender.org/blender/blender/pulls/147060 --- scripts/modules/animsys_refactor.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/modules/animsys_refactor.py b/scripts/modules/animsys_refactor.py index 90d885b4ef1..c187e83167e 100644 --- a/scripts/modules/animsys_refactor.py +++ b/scripts/modules/animsys_refactor.py @@ -13,8 +13,10 @@ __all__ = ( ) import sys + import bpy +from bpy_extras import anim_utils IS_TESTING = False @@ -116,15 +118,15 @@ def id_iter(): yield id_data -def anim_data_actions(anim_data): +def anim_data_actions(anim_data) -> list[tuple[bpy.types.Action, bpy.types.ActionSlot]]: actions = [] - actions.append(anim_data.action) + actions.append((anim_data.action, anim_data.action_slot)) for track in anim_data.nla_tracks: for strip in track.strips: - actions.append(strip.action) + actions.append((strip.action, strip.action_slot)) - # filter out None - return [act for act in actions if act] + # Filter out None actions/slots, because if either is None, there is no animation. + return [(act, slot) for (act, slot) in actions if act and slot] def find_path_new(id_data, data_path, rna_update_from_map, fcurve, log): @@ -157,8 +159,9 @@ def update_data_paths(rna_update, log=sys.stdout): rna_update_from_map.setdefault(ren_from, []).append((ren_class, ren_to, options)) for id_data in id_iter(): + anim_data_ls: list[tuple[bpy.types.ID, bpy.types.AnimData | None]] = [ + (id_data, getattr(id_data, "animation_data", None))] # check node-trees too - anim_data_ls = [(id_data, getattr(id_data, "animation_data", None))] node_tree = getattr(id_data, "node_tree", None) if node_tree: anim_data_ls.append((node_tree, node_tree.animation_data)) @@ -201,8 +204,11 @@ def update_data_paths(rna_update, log=sys.stdout): file=log, ) - for action in anim_data_actions(anim_data): - for fcu in action.fcurves: + for action, action_slot in anim_data_actions(anim_data): + channelbag = anim_utils.action_get_channelbag_for_slot(action, action_slot) + if not channelbag: + continue + for fcu in channelbag.fcurves: data_path = fcu.data_path data_path_new = find_path_new(anim_data_base, data_path, rna_update_from_map, fcu, log) # print(data_path_new)