forked from bookyakuno/Blender-Scramble-Addon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVIEW3D_PT_view3d_name.py
76 lines (64 loc) · 2.23 KB
/
VIEW3D_PT_view3d_name.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 > Sidebar > "Item" Tab > "Item" Panel
import bpy
################
# オペレーター #
################
##########
# パネル #
##########
class VIEW3D_PT_scramble_view3d_name(bpy.types.Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Item"
bl_label = "Item"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
if context.object:
return True
else:
return False
def draw(self, context):
if (IsMenuEnable(__name__.split('.')[-1])):
if context.object:
self.layout.prop(context.object,"name")
else:
self.layout.label(text="",icon="NONE")
# 特に記載がない関数は OBJECT_PT_context_object で定義
row = self.layout.split(factor=0.7,align=True)
row.label(text="To Clipboard", icon='COPYDOWN')
row.operator('object.copy_object_name', icon='OBJECT_DATAMODE', text="")
if (context.active_bone or context.active_pose_bone):
row.operator('object.copy_bone_name', icon='BONE_DATA', text="")# BONE_PT_context_bone.py で定義
row.operator('object.copy_data_name', icon='EDITMODE_HLT', text="")
row = self.layout.split(factor=0.7,align=True)
row.label(text="Use Same Name", icon='LINKED')
row.operator('object.object_name_to_data_name', icon='TRIA_DOWN_BAR', text="")
row.operator('object.data_name_to_object_name', icon='TRIA_UP_BAR', text="")
if context.object:
self.layout.template_ID(context.object, 'data')
if (context.preferences.addons[__name__.partition('.')[0]].preferences.use_disabled_menu):
self.layout.operator('wm.toggle_menu_enable', icon='CANCEL').id = __name__.split('.')[-1]
################
# クラスの登録 #
################
classes = [
VIEW3D_PT_scramble_view3d_name
]
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