Fixed is_action_for_object failing when action had multiple slots

This commit is contained in:
Colin Basnett
2025-08-17 13:19:36 -07:00
parent 8d2f46c2b1
commit 20c8a39f23

View File

@@ -35,7 +35,7 @@ def get_sequences_propnames_from_source(sequence_source: str) -> Tuple[str, str]
def is_action_for_object(obj: Object, action: Action): def is_action_for_object(obj: Object, action: Action):
if action is None or len(action.fcurves) == 0: if len(action.fcurves) == 0:
return False return False
if obj is None or obj.animation_data is None or obj.type != 'ARMATURE': if obj is None or obj.animation_data is None or obj.type != 'ARMATURE':
@@ -43,14 +43,18 @@ def is_action_for_object(obj: Object, action: Action):
armature_data = typing_cast(Armature, obj.data) armature_data = typing_cast(Armature, obj.data)
bone_names = set([x.name for x in armature_data.bones]) bone_names = set([x.name for x in armature_data.bones])
for fcurve in action.fcurves: # The nesting here is absolutely bonkers.
match = re.match(r'pose\.bones\[\"([^\"]+)\"](\[\"([^\"]+)\"])?', fcurve.data_path) for layer in action.layers:
if not match: for strip in layer.strips:
continue for channelbag in strip.channelbags:
bone_name = match.group(1) for fcurve in channelbag.fcurves:
if bone_name in bone_names: match = re.match(r'pose\.bones\[\"([^\"]+)\"](\[\"([^\"]+)\"])?', fcurve.data_path)
return True if not match:
continue
bone_name = match.group(1)
if bone_name in bone_names:
return True
return False return False