Further Fixes to Optimise Armature

This commit is contained in:
Yusarina
2024-11-27 03:41:57 +00:00
parent 503b8f0919
commit 6b6773e70a
+14 -2
View File
@@ -123,7 +123,13 @@ class AvatarToolKit_OT_OptimizeArmature(Operator):
init_progress(context, 9) init_progress(context, 9)
# Store initial bone transforms # Ensure proper object selection and mode
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
armature.select_set(True)
context.view_layer.objects.active = armature
# Store initial transforms
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='EDIT')
initial_transforms = {} initial_transforms = {}
for bone in armature.data.edit_bones: for bone in armature.data.edit_bones:
@@ -169,7 +175,13 @@ class AvatarToolKit_OT_OptimizeArmature(Operator):
bone.matrix = transform['matrix'] bone.matrix = transform['matrix']
update_progress(self, context, t("MMDOptions.armature_optimization_complete")) update_progress(self, context, t("MMDOptions.armature_optimization_complete"))
bpy.ops.object.mode_set(mode='OBJECT')
# Ensure we end in object mode with proper selection
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
armature.select_set(True)
context.view_layer.objects.active = armature
finish_progress(context) finish_progress(context)
return {'FINISHED'} return {'FINISHED'}