Anim: imported action slot named "Slot" when importing BVH/FBX files

Always name the imported action slot "Slot" when importing BVH and FBX
files, for ease of switching between imported Actions.

Note: this is only adjusting the old Python-based FBX importer.

Previously the slot would be named after the file itself (BVH) or had a
combination of the animated object, the animation "stack", and the
animation "layer" (FBX). This meant  that every imported animation would
get another slot name, making Action switching tedious.

Pull Request: https://projects.blender.org/blender/blender/pulls/146601
This commit is contained in:
Sybren A. Stüvel
2025-09-23 15:19:55 +02:00
parent 33ca6456d0
commit e1b6cc2404
2 changed files with 15 additions and 3 deletions

View File

@@ -518,7 +518,13 @@ def bvh_node_dict2armature(
arm_ob_adt = arm_ob.animation_data_create()
action = bpy.data.actions.new(name=bvh_name)
action_slot = action.slots.new(arm_ob.id_type, arm_ob.name)
# Always use the same name for the slot. The Armature is named after the
# BVH file, and so when importing multiple files to get multiple Actions
# for a single character, it is likely that all but one of the Armatures
# is going to be deleted again. It should be simple to switch between
# imported Actions while keeping Slot auto-assignment, which means that
# all Actions should use the same slot name.
action_slot = action.slots.new(arm_ob.id_type, "Slot")
arm_ob_adt.action = action
arm_ob_adt.action_slot = action_slot

View File

@@ -1098,8 +1098,14 @@ def blen_read_animations(fbx_tmpl_astack, fbx_tmpl_alayer, stacks, scene, anim_o
actions[key] = action = bpy.data.actions.new(action_name)
action.use_fake_user = True
# Create an Action Slot. Curves created via action.fcurves will automatically be assigned to it.
action.slots.new(id_data.id_type, action_name)
# Always use the same name for the slot. It should be simple
# to switch between imported Actions while keeping Slot
# auto-assignment, which means that all Actions should use
# the same slot name. As long as there's no separate
# indicator for the "intended object name" for this FBX
# animation, this is the best Blender can do. Maybe the
# 'stack name' would be a better choice?
action.slots.new(id_data.id_type, "Slot")
# If none yet assigned, assign this action to id_data.
if not id_data.animation_data: