CM3D2 Converter.misc_INFO_HT_header
1# 画面右上 (「情報」エリア → ヘッダー) 2import bpy 3import bmesh 4from . import common 5from . import compat 6from .translations.pgettext_functions import * 7 8 9# メニュー等に項目追加 10def menu_func(self, context): 11 self.layout.operator('mesh.vertices_count_checker', icon_value=common.kiss_icon()) 12 13 14@compat.BlRegister() 15class CNV_OT_vertices_count_checker(bpy.types.Operator): 16 bl_idname = 'mesh.vertices_count_checker' 17 bl_label = "頂点数をチェック" 18 bl_description = "選択メッシュがConverterで出力可能な頂点数に収まっているかをチェックします" 19 bl_options = {'REGISTER', 'UNDO'} 20 21 @classmethod 22 def poll(cls, context): 23 ob = context.active_object 24 return ob and ob.type == 'MESH' 25 26 def execute(self, context): 27 me = context.object.data 28 if not me.uv_layers.active: 29 self.report(type={'ERROR'}, message="UVが存在しないので測定できません。") 30 return {'FINISHED'} 31 bm = bmesh.new() 32 bm.from_mesh(me) 33 34 alreadys = {} 35 uv_lay = bm.loops.layers.uv.active 36 37 for face in bm.faces: 38 for loop in face.loops: 39 info = (loop.vert.index, loop[uv_lay].uv.x, loop[uv_lay].uv.y) 40 if info not in alreadys: 41 alreadys[info] = None 42 bm.free() 43 44 inner_count = len(alreadys) 45 real_count = len(me.vertices) 46 if inner_count <= 65535: 47 self.report(type={'INFO'}, message=f_tip_("○ 出力可能な頂点数です、あと約{}頂点ほど余裕があります (頂点数:{}(+{}) UV分割で増加:+{}%)", 65535 - inner_count, real_count, inner_count - real_count, int(inner_count / real_count * 100))) 48 else: 49 self.report(type={'ERROR'}, message=f_tip_("× 出力できない頂点数です、あと約{}頂点減らしてください (頂点数:{}(+{}) UV分割で増加:+{}%)", inner_count - 65535, real_count, inner_count - real_count, int(inner_count / real_count * 100))) 50 51 return {'FINISHED'}
@compat.BlRegister()
class
CNV_OT_vertices_count_checker15@compat.BlRegister() 16class CNV_OT_vertices_count_checker(bpy.types.Operator): 17 bl_idname = 'mesh.vertices_count_checker' 18 bl_label = "頂点数をチェック" 19 bl_description = "選択メッシュがConverterで出力可能な頂点数に収まっているかをチェックします" 20 bl_options = {'REGISTER', 'UNDO'} 21 22 @classmethod 23 def poll(cls, context): 24 ob = context.active_object 25 return ob and ob.type == 'MESH' 26 27 def execute(self, context): 28 me = context.object.data 29 if not me.uv_layers.active: 30 self.report(type={'ERROR'}, message="UVが存在しないので測定できません。") 31 return {'FINISHED'} 32 bm = bmesh.new() 33 bm.from_mesh(me) 34 35 alreadys = {} 36 uv_lay = bm.loops.layers.uv.active 37 38 for face in bm.faces: 39 for loop in face.loops: 40 info = (loop.vert.index, loop[uv_lay].uv.x, loop[uv_lay].uv.y) 41 if info not in alreadys: 42 alreadys[info] = None 43 bm.free() 44 45 inner_count = len(alreadys) 46 real_count = len(me.vertices) 47 if inner_count <= 65535: 48 self.report(type={'INFO'}, message=f_tip_("○ 出力可能な頂点数です、あと約{}頂点ほど余裕があります (頂点数:{}(+{}) UV分割で増加:+{}%)", 65535 - inner_count, real_count, inner_count - real_count, int(inner_count / real_count * 100))) 49 else: 50 self.report(type={'ERROR'}, message=f_tip_("× 出力できない頂点数です、あと約{}頂点減らしてください (頂点数:{}(+{}) UV分割で増加:+{}%)", inner_count - 65535, real_count, inner_count - real_count, int(inner_count / real_count * 100))) 51 52 return {'FINISHED'}
def
execute(self, context):
27 def execute(self, context): 28 me = context.object.data 29 if not me.uv_layers.active: 30 self.report(type={'ERROR'}, message="UVが存在しないので測定できません。") 31 return {'FINISHED'} 32 bm = bmesh.new() 33 bm.from_mesh(me) 34 35 alreadys = {} 36 uv_lay = bm.loops.layers.uv.active 37 38 for face in bm.faces: 39 for loop in face.loops: 40 info = (loop.vert.index, loop[uv_lay].uv.x, loop[uv_lay].uv.y) 41 if info not in alreadys: 42 alreadys[info] = None 43 bm.free() 44 45 inner_count = len(alreadys) 46 real_count = len(me.vertices) 47 if inner_count <= 65535: 48 self.report(type={'INFO'}, message=f_tip_("○ 出力可能な頂点数です、あと約{}頂点ほど余裕があります (頂点数:{}(+{}) UV分割で増加:+{}%)", 65535 - inner_count, real_count, inner_count - real_count, int(inner_count / real_count * 100))) 49 else: 50 self.report(type={'ERROR'}, message=f_tip_("× 出力できない頂点数です、あと約{}頂点減らしてください (頂点数:{}(+{}) UV分割で増加:+{}%)", inner_count - 65535, real_count, inner_count - real_count, int(inner_count / real_count * 100))) 51 52 return {'FINISHED'}
Inherited Members
- bpy_types.Operator
- as_keywords
- poll_message_set
- builtins.bpy_struct
- keys
- values
- items
- get
- pop
- as_pointer
- keyframe_insert
- keyframe_delete
- driver_add
- driver_remove
- is_property_set
- property_unset
- is_property_readonly
- is_property_overridable_library
- property_overridable_library_set
- path_resolve
- path_from_id
- type_recast
- bl_rna_get_subclass_py
- bl_rna_get_subclass
- id_properties_ensure
- id_properties_clear
- id_properties_ui
- id_data