Move Separate By to Additional Tools

Move Separate BY to Additional tools, makes no sense having these smaller functions in it's own file.
This commit is contained in:
Yusarina
2024-09-27 22:59:45 +01:00
parent 909b104882
commit 503ba52b9b
3 changed files with 42 additions and 46 deletions
+41
View File
@@ -119,3 +119,44 @@ class AvatarToolKit_OT_DeleteBoneConstraints(Operator):
self.report({'INFO'}, t("Tools.delete_bone_constraints.success").format(constraints_removed=constraints_removed))
return {'FINISHED'}
@register_wrap
class AvatarToolKit_OT_SeparateByMaterials(Operator):
bl_idname = "avatar_toolkit.separate_by_materials"
bl_label = t("Tools.separate_by_materials.label")
bl_description = t("Tools.separate_by_materials.desc")
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context: Context) -> bool:
return context.active_object and context.active_object.type == 'MESH'
def execute(self, context: Context) -> set[str]:
obj = context.active_object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.separate(type='MATERIAL')
bpy.ops.object.mode_set(mode='OBJECT')
self.report({'INFO'}, t("Tools.separate_by_materials.success"))
return {'FINISHED'}
@register_wrap
class AvatarToolKit_OT_SeparateByLooseParts(Operator):
bl_idname = "avatar_toolkit.separate_by_loose_parts"
bl_label = t("Tools.separate_by_loose_parts.label")
bl_description = t("Tools.separate_by_loose_parts.desc")
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context: Context) -> bool:
return context.active_object and context.active_object.type == 'MESH'
def execute(self, context: Context) -> set[str]:
obj = context.active_object
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.mode_set(mode='OBJECT')
self.report({'INFO'}, t("Tools.separate_by_loose_parts.success"))
return {'FINISHED'}