bpy_types.Panel

class DATA_PT_context_arm:
def draw_funcs[1](self, context):
 18def menu_func(self, context):
 19    import re
 20    ob = context.active_object
 21    if not ob or ob.type != 'ARMATURE':
 22        return
 23
 24    arm = ob.data
 25    is_boxed = False
 26
 27    bone_data_count = 0
 28    if 'BoneData:0' in arm and 'LocalBoneData:0' in arm:
 29        for key in arm.keys():
 30            if re.search(r'^(Local)?BoneData:\d+$', key):
 31                bone_data_count += 1
 32    enabled_clipboard = False
 33    clipboard = context.window_manager.clipboard
 34    if 'BoneData:' in clipboard and 'LocalBoneData:' in clipboard:
 35        enabled_clipboard = True
 36    if bone_data_count or enabled_clipboard:
 37        if not is_boxed:
 38            box = self.layout.box()
 39            box.label(text="CM3D2用", icon_value=common.kiss_icon())
 40            is_boxed = True
 41
 42        col = box.column(align=True)
 43        row = col.row(align=True)
 44        row.label(text="ボーン情報", icon='CONSTRAINT_BONE')
 45        sub_row = row.row()
 46        sub_row.alignment = 'RIGHT'
 47        if bone_data_count:
 48            sub_row.label(text=str(bone_data_count), icon='CHECKBOX_HLT')
 49        else:
 50            sub_row.label(text="0", icon='CHECKBOX_DEHLT')
 51        row = col.row(align=True)
 52        row.operator('object.copy_armature_bone_data_property', icon='COPYDOWN', text="コピー")
 53        row.operator('object.paste_armature_bone_data_property', icon='PASTEDOWN', text="貼付け")
 54        row.operator('object.remove_armature_bone_data_property', icon='X', text="")
 55
 56    flag = False
 57    for bone in arm.bones:
 58        if not flag and re.search(r'[_ ]([rRlL])[_ ]', bone.name):
 59            flag = True
 60        if not flag and bone.name.count('*') == 1:
 61            if re.search(r'\.([rRlL])$', bone.name):
 62                flag = True
 63        if flag:
 64            if not is_boxed:
 65                box = self.layout.box()
 66                box.label(text="CM3D2用", icon_value=common.kiss_icon())
 67                is_boxed = True
 68
 69            col = box.column(align=True)
 70            col.label(text="ボーン名変換", icon='SORTALPHA')
 71            row = col.row(align=True)
 72            row.operator('armature.decode_cm3d2_bone_names', text="CM3D2 → Blender", icon='BLENDER')
 73            row.operator('armature.encode_cm3d2_bone_names', text="Blender → CM3D2", icon_value=common.kiss_icon())
 74            break
 75        
 76    if bone_data_count:
 77        col = box.column(align=True)
 78        col.label(text="Armature Operators", icon=compat.icon('OUTLINER_OB_ARMATURE'))
 79        col.operator("object.add_cm3d2_twist_bones", text="Connect Twist Bones", icon=compat.icon('CONSTRAINT_BONE'))
 80        col.operator("object.cleanup_scale_bones"  , text="Cleanup Scale Bones", icon=compat.icon('X'              ))
 81        
 82    if 'is T Stance' in arm:
 83        if not is_boxed:
 84            box = self.layout.box()
 85            box.label(text="CM3D2用", icon_value=common.kiss_icon())
 86            is_boxed = True
 87
 88        col = box.column(align=True)
 89        if arm['is T Stance']:
 90            pose_text = "Armature State: Primed"
 91        else:
 92            pose_text = "Armature State: Normal"
 93        col.label(text=pose_text, icon='POSE_HLT')
 94        col.enabled = bpy.ops.poselib.apply_pose.poll()
 95
 96        row = col.row(align=True)
 97        
 98        sub_row = row.row(align=True)
 99        op = sub_row.operator('poselib.apply_pose', icon='ARMATURE_DATA', text="Original")#, depress=(context.scene.frame_current % 2 == arm['is T Stance']))
100        op.pose_index = arm['is T Stance']
101        #if context.scene.frame_current % 2 == op.value:
102        #    sub_row.enabled = False
103        
104        sub_row = row.row(align=True)
105        op = sub_row.operator('poselib.apply_pose', icon=compat.icon('OUTLINER_DATA_ARMATURE'), text="Pose data")#, depress=(context.scene.frame_current % 2 != arm['is T Stance']))
106        op.pose_index = not arm['is T Stance']
107        #if context.scene.frame_current % 2 == op.value:
108        #    sub_row.enabled = False
109        
110        row = col.row(align=True)
111        
112        sub_row = row.row(align=True)
113        sub_row.operator_context = 'EXEC_DEFAULT'
114        op = sub_row.operator('pose.apply_prime_field', icon=compat.icon('FILE_REFRESH'), text="Swap Prime Field")
115        op.is_swap_prime_field = True
class DATA_PT_modifiers:
def draw_funcs[1](self, context):
18def menu_func(self, context):
19    ob = context.active_object
20    if ob:
21        if ob.type == 'MESH':
22            me = ob.data
23            if len(ob.modifiers):
24                self.layout.operator('object.forced_modifier_apply', icon_value=common.kiss_icon())
class DATA_PT_vertex_groups:
def draw_funcs[1](self, context):
10def menu_func(self, context):
11    ob = context.active_object
12    if not ob or len(ob.vertex_groups) == 0 and ob.type != 'MESH':
13        return
14
15    flag = False
16    for vertex_group in ob.vertex_groups:
17        if not flag and re.search(r'[_ ]([rRlL])[_ ]', vertex_group.name):
18            flag = True
19        if not flag and vertex_group.name.count('*') == 1:
20            if re.search(r'\.([rRlL])$', vertex_group.name):
21                flag = True
22        if flag:
23            col = self.layout.column(align=True)
24            col.label(text="CM3D2用 頂点グループ名変換", icon_value=common.kiss_icon())
25            row = col.row(align=True)
26            row.operator('object.decode_cm3d2_vertex_group_names', icon='BLENDER', text="CM3D2 → Blender")
27            row.operator('object.encode_cm3d2_vertex_group_names', icon_value=common.kiss_icon(), text="Blender → CM3D2")
28            break
class IMAGE_PT_image_properties:
def draw_funcs[1](self, context):
 7def menu_func(self, context):
 8    img = getattr(context, 'edit_image')
 9    if img and 'cm3d2_path' in img:
10        box = self.layout.box()
11        box.label(text="CM3D2用", icon_value=common.kiss_icon())
12        box.prop(img, '["cm3d2_path"]', icon='ANIM_DATA', text="内部パス")
class OBJECT_PT_context_object:
def draw_funcs[1](self, context):
11def menu_func(self, context):
12    ob = context.object
13    if not ob or ob.type != 'MESH':
14        return
15
16    bone_data_count = 0
17    if 'BoneData:0' in ob and 'LocalBoneData:0' in ob:
18        for key in ob.keys():
19            if re.search(r'^(Local)?BoneData:\d+$', key):
20                bone_data_count += 1
21    enabled_clipboard = False
22    clipboard = context.window_manager.clipboard
23    if 'BoneData:' in clipboard and 'LocalBoneData:' in clipboard:
24        enabled_clipboard = True
25
26    if bone_data_count or enabled_clipboard:
27        col = self.layout.column(align=True)
28        row = col.row(align=True)
29        row.label(text="CM3D2用ボーン情報", icon_value=common.kiss_icon())
30        sub_row = row.row()
31        sub_row.alignment = 'RIGHT'
32        if 'BoneData:0' in ob and 'LocalBoneData:0' in ob:
33            bone_data_count = 0
34            for key in ob.keys():
35                if re.search(r'^(Local)?BoneData:\d+$', key):
36                    bone_data_count += 1
37            sub_row.label(text=str(bone_data_count), icon='CHECKBOX_HLT')
38        else:
39            sub_row.label(text="0", icon='CHECKBOX_DEHLT')
40        row = col.row(align=True)
41        row.operator('object.copy_object_bone_data_property', icon='COPYDOWN', text="コピー")
42        row.operator('object.paste_object_bone_data_property', icon='PASTEDOWN', text="貼付け")
43        row.operator('object.remove_object_bone_data_property', icon='X', text="")
class OBJECT_PT_transform:
def draw_funcs[1](self, context):
14def menu_func(self, context):
15    self.layout.operator('object.sync_object_transform'   , icon_value=common.kiss_icon())
16    self.layout.operator('object.align_to_cm3d2_base_bone', icon_value=common.kiss_icon())
class RENDER_PT_context:
def draw_funcs[2](self, context):
16def menu_func(self, context):
17    self.layout.operator(CNV_OT_render_cm3d2_icon.bl_idname, icon_value=common.kiss_icon())
class VIEW3D_PT_tools_weightpaint_options:
def draw_funcs[1](self, context):
11def menu_func(self, context):
12    icon_id = common.kiss_icon()
13    box = self.layout.box()
14    column = box.column(align=False)
15    column.prop(context.active_object.data, 'use_paint_mask_vertex', icon='VERTEXSEL', text="頂点選択モード")
16    column.operator('mesh.selected_mesh_vertex_group_blur', text="選択部をぼかす", icon_value=icon_id)
17    column.operator('mesh.selected_mesh_vertex_group_calculation', text="選択部に四則演算", icon_value=icon_id)