forked from bookyakuno/Blender-Scramble-Addon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VIEW3D_MT_select_edit_armature.py
76 lines (63 loc) · 2.45 KB
/
VIEW3D_MT_select_edit_armature.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# 「3Dビュー」エリア > アーマチュアの「編集」モード > 「選択」メニュー
# "3D View" Area > "Edit" Mode with Armature > "Select" Menu
import bpy
from bpy.props import *
################
# オペレーター #
################
class SelectOneAndPathForEdit(bpy.types.Operator):
bl_idname = "armature.select_one_and_path"
bl_label = "Select Bones to Mouse"
bl_description = "Select bones which exist between selected bones and mouse position"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
if context.selected_bones or context.selected_pose_bones:
return True
return False
def execute(self, context):
bpy.ops.object.mode_set(mode='POSE')
bpy.ops.pose.select_one_and_path('INVOKE_DEFAULT')
bpy.ops.object.mode_set(mode='EDIT')
return {'FINISHED'}
################
# クラスの登録 #
################
classes = [
SelectOneAndPathForEdit
]
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
################
# メニュー追加 #
################
# メニューのオン/オフの判定
def IsMenuEnable(self_id):
for id in bpy.context.preferences.addons[__name__.partition('.')[0]].preferences.disabled_menu.split(','):
if (id == self_id):
return False
else:
return True
# メニューを登録する関数
def menu(self, context):
if (IsMenuEnable(__name__.split('.')[-1])):
#以下は全て VIEW3D_MT_select_pose で定義
self.layout.separator()
self.layout.operator('pose.select_path', icon='PLUGIN')
self.layout.operator('pose.select_parent_end', icon='PLUGIN')
self.layout.operator('pose.select_children_end', icon='PLUGIN')
self.layout.operator('pose.select_both_end', icon='PLUGIN')
self.layout.separator()
self.layout.operator('pose.select_axis_over', icon='PLUGIN')
self.layout.operator('pose.select_serial_number_name_bone', icon='PLUGIN')
self.layout.operator('pose.select_move_symmetry_name_bones', icon='PLUGIN').keep_current = True
self.layout.separator()
self.layout.operator('pose.select_move_symmetry_name_bones', text="Change Selection (Flipped-Name)", icon='PLUGIN').keep_current = False
self.layout.operator(SelectOneAndPathForEdit.bl_idname, icon='PLUGIN')
if (context.preferences.addons[__name__.partition('.')[0]].preferences.use_disabled_menu):
self.layout.separator()
self.layout.operator('wm.toggle_menu_enable', icon='CANCEL').id = __name__.split('.')[-1]