Typing 3
This commit is contained in:
+13
-10
@@ -1,23 +1,25 @@
|
||||
import bpy
|
||||
from typing import List, Optional
|
||||
from bpy.types import Operator, Context, Object
|
||||
from ..core.register import register_wrap
|
||||
from ..core.common import fix_uv_coordinates
|
||||
|
||||
@register_wrap
|
||||
class JoinAllMeshes(bpy.types.Operator):
|
||||
class JoinAllMeshes(Operator):
|
||||
bl_idname = "avatar_toolkit.join_all_meshes"
|
||||
bl_label = "Join All Meshes"
|
||||
bl_description = "Join all meshes in the scene"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
def poll(cls, context: Context) -> bool:
|
||||
return context.mode == 'OBJECT'
|
||||
|
||||
def execute(self, context):
|
||||
def execute(self, context: Context) -> set:
|
||||
self.join_all_meshes(context)
|
||||
return {'FINISHED'}
|
||||
|
||||
def join_all_meshes(self, context):
|
||||
def join_all_meshes(self, context: Context) -> None:
|
||||
if not bpy.data.objects:
|
||||
self.report({'INFO'}, "No objects in the scene")
|
||||
return
|
||||
@@ -25,7 +27,7 @@ class JoinAllMeshes(bpy.types.Operator):
|
||||
bpy.ops.object.mode_set(mode='OBJECT')
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
|
||||
meshes = [obj for obj in bpy.data.objects if obj.type == 'MESH']
|
||||
meshes: List[Object] = [obj for obj in bpy.data.objects if obj.type == 'MESH']
|
||||
for mesh in meshes:
|
||||
mesh.select_set(True)
|
||||
|
||||
@@ -41,22 +43,22 @@ class JoinAllMeshes(bpy.types.Operator):
|
||||
self.report({'WARNING'}, "No mesh objects selected")
|
||||
|
||||
@register_wrap
|
||||
class JoinSelectedMeshes(bpy.types.Operator):
|
||||
class JoinSelectedMeshes(Operator):
|
||||
bl_idname = "avatar_toolkit.join_selected_meshes"
|
||||
bl_label = "Join Selected Meshes"
|
||||
bl_description = "Join selected meshes"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
def poll(cls, context: Context) -> bool:
|
||||
return context.mode == 'OBJECT'
|
||||
|
||||
def execute(self, context):
|
||||
def execute(self, context: Context) -> set:
|
||||
self.join_selected_meshes(context)
|
||||
return {'FINISHED'}
|
||||
|
||||
def join_selected_meshes(self, context):
|
||||
selected_objects = [obj for obj in bpy.context.selected_objects if obj.type == 'MESH']
|
||||
def join_selected_meshes(self, context: Context) -> None:
|
||||
selected_objects: List[Object] = [obj for obj in bpy.context.selected_objects if obj.type == 'MESH']
|
||||
|
||||
if not selected_objects:
|
||||
self.report({'WARNING'}, "No mesh objects selected")
|
||||
@@ -78,3 +80,4 @@ class JoinSelectedMeshes(bpy.types.Operator):
|
||||
self.report({'INFO'}, "Selected meshes joined successfully")
|
||||
else:
|
||||
self.report({'WARNING'}, "No mesh objects selected")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user