diff --git a/core/common.py b/core/common.py index e0093e9..2220f9e 100644 --- a/core/common.py +++ b/core/common.py @@ -313,6 +313,7 @@ def join_mesh_objects(context: Context, meshes: List[Object], progress: Optional for mesh in valid_meshes: mesh.select_set(True) + mesh.hide_set(False) context.view_layer.objects.active = valid_meshes[0] diff --git a/functions/custom_tools/armature_merging.py b/functions/custom_tools/armature_merging.py index 7cd0807..c305d13 100644 --- a/functions/custom_tools/armature_merging.py +++ b/functions/custom_tools/armature_merging.py @@ -4,6 +4,7 @@ from typing import List, Optional, Dict, Set, Tuple, Any from bpy.types import Context, Object, Operator, ArmatureModifier, EditBone, VertexGroup, Mesh, ShapeKey from ...core.logging_setup import logger from ...core.translations import t +import traceback from ...core.common import ( get_all_meshes, fix_zero_length_bones, @@ -73,8 +74,8 @@ class AvatarToolkit_OT_MergeArmature(bpy.types.Operator): return {'FINISHED'} except Exception as e: - logger.error(f"Error merging armatures: {str(e)}") - self.report({'ERROR'}, str(e)) + logger.error(f"Error merging armatures:", exception=e) + self.report({'ERROR'}, traceback.format_exc()) return {'CANCELLED'} def delete_rigidbodies_and_joints(armature: Object) -> None: @@ -149,6 +150,9 @@ def merge_armatures( # Store meshes that need to be reparented meshes_to_reparent = [obj for obj in bpy.data.objects if obj.type == 'MESH' and obj.parent == merge_armature] + + base_armature.hide_set(False) + merge_armature.hide_set(False) # Check transforms early if not validate_merge_armature_transforms(base_armature, merge_armature, None, tolerance): @@ -170,6 +174,8 @@ def merge_armatures( fix_zero_length_bones(base_armature) fix_zero_length_bones(merge_armature) + + # Store original parent relationships original_parents: Dict[str, Optional[str]] = {} merge_armature_data: bpy.types.Armature = merge_armature.data @@ -187,9 +193,9 @@ def merge_armatures( for standard,bone_name in identified_bone_names_source.items(): if standard in identifed_base_bone_names: #if the bone we are at on our merge armature has a standard name translation for the target armature merge_armature_data.edit_bones[bone_name].name = identifed_base_bone_names[standard] #change it's name to the one on the target merge to armature's coorisponding standard bone - bone_name = merge_armature_data.edit_bones[bone_name].name + bone_name = identifed_base_bone_names[standard] #adjust original parents list to point to the new name. - for child_bone in merge_armature_data.edit_bones[bone_name]: + for child_bone in merge_armature_data.edit_bones[bone_name].children: original_parents[child_bone.name] = bone_name #then remove so it doesn't clash when merged. merge_armature_data.edit_bones.remove(merge_armature_data.edit_bones[bone_name]) @@ -201,6 +207,7 @@ def merge_armatures( bpy.ops.object.select_all(action='DESELECT') base_armature.select_set(True) merge_armature.select_set(True) + bpy.context.view_layer.objects.active = base_armature bpy.ops.object.join() diff --git a/functions/custom_tools/force_apply_modifier.py b/functions/custom_tools/force_apply_modifier.py index 2d478ab..d0446e3 100644 --- a/functions/custom_tools/force_apply_modifier.py +++ b/functions/custom_tools/force_apply_modifier.py @@ -27,7 +27,7 @@ from ...core.armature_validation import validate_armature class AvatarToolkit_OT_ApplyModifierForShapkeyObj(bpy.types.Operator): """Operator for forcing the application of a modifier. A shortened way of saying \"Apply modifier for object with shapekeys\"""" - bl_idname: str = 'avatar_toolkit.merge_armatures' + bl_idname: str = 'avatar_toolkit.apply_shapekey_force' bl_label: str = t('Tools.apply_modifier_on_shapekey_obj') bl_description: str = t('Tools.apply_modifier_on_shapekey_obj_desc') bl_options: Set[str] = {'REGISTER', 'UNDO'}