From 9e92ff7a611b14c26aa9bd6647354e1f620bfea9 Mon Sep 17 00:00:00 2001 From: Adam Crockett Date: Thu, 4 Apr 2024 21:41:26 +0100 Subject: [PATCH 1/2] After import rename each Armature using the filename that Mixamo provides --- mixamoroot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mixamoroot.py b/mixamoroot.py index 285001d..c8792e1 100644 --- a/mixamoroot.py +++ b/mixamoroot.py @@ -283,6 +283,12 @@ def import_armature(filepath, root_bone_name="Root", hip_bone_name="mixamorig:Hi imported_actions = [x.animation_data.action for x in imported_objects if x.animation_data] print("[Mixamo Root] Now importing: " + str(filepath)) imported_actions[0].name = Path(filepath).resolve().stem # Only reads the first animation associated with an imported armature + imported_armatures = [obj for obj in imported_objects if obj.type == 'ARMATURE'] + + + if imported_armatures: + armature = imported_armatures[0] + armature.name = Path(filepath).resolve().stem if insert_root: add_root_bone(root_bone_name, hip_bone_name, remove_prefix, name_prefix) From 3f0529997ff4b3cb80dc268d598321795ba61737 Mon Sep 17 00:00:00 2001 From: Adam Crockett Date: Thu, 4 Apr 2024 22:59:36 +0100 Subject: [PATCH 2/2] In some cases an extra slash was being added and broke renaming --- mixamoroot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mixamoroot.py b/mixamoroot.py index c8792e1..dd46944 100644 --- a/mixamoroot.py +++ b/mixamoroot.py @@ -281,7 +281,7 @@ def import_armature(filepath, root_bone_name="Root", hip_bone_name="mixamorig:Hi imported_objects = set(bpy.context.scene.objects) - old_objs imported_actions = [x.animation_data.action for x in imported_objects if x.animation_data] - print("[Mixamo Root] Now importing: " + str(filepath)) + print("[Mixamo Root] Now importing: " + str(filepath), filepath) imported_actions[0].name = Path(filepath).resolve().stem # Only reads the first animation associated with an imported armature imported_armatures = [obj for obj in imported_objects if obj.type == 'ARMATURE'] @@ -345,7 +345,7 @@ def get_all_anims(source_dir, root_bone_name="Root", hip_bone_name="mixamorig:Hi for file in files: print("file: " + str(file)) try: - filepath = source_dir+"/"+file + filepath = os.path.join(source_dir, file) import_armature(filepath, root_bone_name, hip_bone_name, remove_prefix, name_prefix, insert_root, delete_armatures) imported_objects = set(bpy.context.scene.objects) - old_objs if delete_armatures and num_files > 1: