-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathinfo_header_useful.py
605 lines (407 loc) · 17 KB
/
info_header_useful.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy, codecs, os.path
import bpy
import mathutils
import os.path
import os, sys
import subprocess
import fnmatch
from bpy.props import IntProperty, FloatProperty, EnumProperty
from bpy.props import FloatVectorProperty, StringProperty
# アドオン情報
bl_info = {
"name" : "info_header_useful",
"author" : "Bookyakuno",
"version" : (0, 4),
"blender" : (2, 79),
"location" : "info > header > left, 3D view > header > left",
"description" : "check the important stator with the header.",
"warning" : "",
"wiki_url" : "",
"tracker_url" : "",
"category" : "UI"
}
from bpy.types import Operator, AddonPreferences
###
import struct
# 翻訳辞書
translation_dict = {
"en_US": {
},
"ja_JP": {
("*", "check the important stator with the header."):
"重要なステータスをヘッダーで確認できます",
("*", "- current frame"):
"・カレントフレーム",
("*", "- Auto Keyframe mode"):
"・自動キーフレームモード",
("*", "- Recently opened file list, latest automatic backup"):
"・最近開いたファイル一覧、最新の自動バックアップ",
("*", "- Change object name"):
"・オブジェクト名の変更",
("*", "- Mirror in various modes"):
"・各種モードでのミラー",
("*", "- If global undo is turned off, a warning indication"):
"・グローバルアンドゥがオフになっていると警告表示",
("*", "- When Automatic keyframe insertion is ON, the header BG color becomes Red"):
"・自動キーフレームモードがオンだとヘッダー背景色を「赤」に変更",
("*", "- When Dyntopo is ON, the header BG color becomes Yellow"):
"・Dyntopoがオンだとヘッダー背景色を「黄色」に変更",
("*", "- Dyntopo"):
"・Dyntopo",
}
}
class info_header_useful_MenuPrefs(bpy.types.AddonPreferences):
bl_idname = __name__
# def_header_col = bpy.props.FloatVectorProperty(name="Default", default=(0.2, 0.2, 0.2, 1), size=4, subtype="COLOR", min=0, max=1)
# header_color = bpy.props.BoolProperty(
# name="header_color",
# description="header_color",
# default=False)
def draw(self, context):
layout = self.layout
split = layout.split()
col = split.column()
# col.prop(self, "def_header_col")
# col.prop(self, "header_color")
layout.label(
text="- current frame")
layout.label(
text="- Auto Keyframe mode")
layout.label(
text="- Recently opened file list, latest automatic backup")
layout.label(
text="- Change object name")
layout.label(
text="- Mirror in various modes")
layout.label(
text="- When Automatic keyframe insertion is ON, the header BG color becomes Red")
layout.label(
text="- When Dyntopo is ON, the header BG color becomes Yellow")
layout.label(
text="- Dyntopo")
# row.operator("wm.url_open", text="Download : github").url = "https://github.com/bookyakuno/-Blender-/blob/master/angle_select_click.py"
# row.operator("wm.url_open", text="Donation $3 : gumroad").url = "https://gumroad.com/l/LXbX"
class RecoverLatestAutoSave_x(bpy.types.Operator):
bl_idname = "wm.recover_latest_auto_save_x"
bl_label = "最新の自動保存の読み込み"
bl_description = "復元するために自動的に保存したファイルの最新ファイルを開きます"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
tempPath = context.user_preferences.filepaths.temporary_directory
lastFile = None
for fileName in fnmatch.filter(os.listdir(tempPath), "*.blend"):
path = os.path.join(tempPath, fileName)
if (lastFile):
mtime = os.stat(path).st_mtime
if (lastTime < mtime and fileName != "quit.blend"):
lastFile = path
lastTime = mtime
else:
lastFile = path
lastTime = os.stat(path).st_mtime
bpy.ops.wm.recover_auto_save(filepath=lastFile)
self.report(type={"INFO"}, message="最新の自動保存ファイルを読み込みました")
return {'FINISHED'}
class INFO_HT_header_recent_files_x(bpy.types.Menu):
bl_idname = 'yyyt'
bl_label = "Recent Files"
def draw(self, context):
recent_files = os.path.join(bpy.utils.user_resource('CONFIG'), "recent-files.txt")
file = codecs.open(recent_files, 'r', 'utf-8-sig')
for index, blend_path in enumerate(file.readlines()):
if not blend_path: continue
blend_path = blend_path.rstrip("\r\n")
base_name = os.path.splitext( os.path.basename(blend_path) )[0]
row = self.layout.row()
row.operator_context = 'EXEC_DEFAULT'
row.operator('wm.open_mainfile', icon='FILE_BLEND', text=base_name).filepath = blend_path
if index == 0:
self.layout.separator()
self.layout.separator()
row = self.layout.row()
row.operator('wm.recover_latest_auto_save_x' , icon='PREVIEW_RANGE')
file.close()
# ヘッダーに項目追加
def veiw3d_header_menu_x(self, context):
layout = self.layout
window = context.window
scene = context.scene
rd = scene.render
userpref = context.user_preferences
system = userpref.system
edit = userpref.edit
row = layout.row()
col = row.column()
# # # ヘッダーカラー
current_theme = bpy.context.user_preferences.themes.items()[0][0]
texed = bpy.context.user_preferences.themes[current_theme].view_3d
def hex_to_rgb_dyn(rgb_str):
int_tuple = struct.unpack('BBB', bytes.fromhex(rgb_str))
return tuple([val/255 for val in int_tuple])
if context.mode == 'SCULPT':
if bpy.context.sculpt_object.use_dynamic_topology_sculpting == True:
texed.space.header = hex_to_rgb_dyn('654600')
else:
texed.space.header = hex_to_rgb_dyn('333333')
else:
texed.space.header = hex_to_rgb_dyn('333333')
# # # ヘッダーカラー
# =====================================================
# グローバルアンドゥを有功
# =====================================================
if bpy.context.user_preferences.edit.use_global_undo== False:
col.prop(edit, "use_global_undo", icon="ERROR",text="")
# =====================================================
# テクスチャペイント
# =====================================================
if context.image_paint_object:
col = layout.column(align=True)
row = col.row(align=True)
# シンメトリー
toolsettings = context.tool_settings
ipaint = toolsettings.image_paint
row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
settings = self.paint_settings(context)
brush = settings.brush
col = layout.column()
col.label(text="Stroke Method:")
col.prop(brush, "stroke_method", text="")
# =====================================================
# ウェイトペイント
# =====================================================
mode_string = context.mode
if mode_string in {'PAINT_WEIGHT'}:
obj = context.weight_paint_object
mesh = obj.data
self.layout.prop(mesh, "use_mirror_x",text="",icon="MOD_MIRROR")
# =====================================================
# アーマチュアミラー
# =====================================================
obj = context.active_object
mode_string = context.mode
edit_object = context.edit_object
gp_edit = context.gpencil_data and context.gpencil_data.use_stroke_edit_mode
mode = obj.mode
if (mode == 'EDIT' and obj.type == 'MESH' or mode == 'EDIT' and 'ARMATURE'):
arm = context.active_object.data
self.layout.prop(arm, "use_mirror_x",text="",icon="MOD_MIRROR")
# =====================================================
# スカルプト
# =====================================================
if context.sculpt_object:
col = layout.column(align=True)
row = col.row(align=True)
# =====================================================
# シンメトリー
# =====================================================
sculpt = context.tool_settings.sculpt
row.scale_x = 0.5
row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
# =====================================================
# ダイナトポ
# =====================================================
WM = context.window_manager
toolsettings = context.tool_settings
sculpt = toolsettings.sculpt
if len(context.selected_objects) >= 1 :
# if bpy.context.scene.tool_settings.use_keyframe_insert_auto == True:
# texed.space.header = hex_to_rgb('670000')
#Detail Size
row.separator()
row = layout.row(align=True)
row.operator("object.update_dyntopo", text=" ", icon='FILE_TICK')
row.scale_x = 0.5
row.prop(WM, "detail_size", text="")
# row.scale_x = 1.2
row.separator()
if context.sculpt_object.use_dynamic_topology_sculpting:
row.operator("sculpt.dynamic_topology_toggle", icon='CANCEL', text="")
else:
row.operator("sculpt.dynamic_topology_toggle", icon='MOD_REMESH', text="")
row.separator()
if not bpy.context.object.mode == 'SCULPT':
layout.prop(WM, "subdivide_mesh", text="Subdivide")
if WM.subdivide_mesh:
layout.prop(WM, "use_sharps", text="Sharp Edges")
layout.prop(WM, "smooth_mesh", text="", icon='MOD_SMOOTH')
layout.prop(WM, "update_detail_flood_fill", text="", icon='MOD_DECIM')
if (sculpt.detail_type_method == 'CONSTANT'):
layout.prop(sculpt, "constant_detail_resolution", text="")
# layout.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
elif (sculpt.detail_type_method == 'BRUSH'):
layout.prop(sculpt, "detail_percent", text="")
else:
layout.prop(sculpt, "detail_size", text="")
userpref = context.user_preferences
view = userpref.view
layout.prop(view, "use_auto_perspective", text="", icon="CAMERA_DATA")
# ヘッダーに項目追加
def info_header_menu_x(self, context):
layout = self.layout
window = context.window
scene = context.scene
rd = scene.render
layout.prop(scene, "frame_current", text="")
toolsettings = context.tool_settings
screen = context.screen
userprefs = context.user_preferences
row = layout.row(align=True)
row.prop(toolsettings, "use_keyframe_insert_auto", text="", toggle=True)
if toolsettings.use_keyframe_insert_auto:
current_theme = bpy.context.user_preferences.themes.items()[0][0]
texed = bpy.context.user_preferences.themes[current_theme].view_3d
def hex_to_rgb_auto_key(rgb_str):
int_tuple = struct.unpack('BBB', bytes.fromhex(rgb_str))
return tuple([val/255 for val in int_tuple])
if bpy.context.scene.tool_settings.use_keyframe_insert_auto == True:
texed.space.header = hex_to_rgb_auto_key('670000')
else:
texed.space.header = hex_to_rgb_auto_key('333333')
# if bpy.context.sculpt_object.use_dynamic_topology_sculpting == True:
# texed.space.header = hex_to_rgb('654600')
row.prop(toolsettings, "use_keyframe_insert_keyingset", text="", toggle=True)
if screen.is_animation_playing and not userprefs.edit.use_keyframe_insert_available:
subsub = row.row(align=True)
subsub.prop(toolsettings, "use_record_with_nla", toggle=True)
# 最近使ったファイル
# self.layout.menu('INFO_MT_file_open_recent', icon='OPEN_RECENT', text="")
# layout.menu("INFO_MT_file_open_recent", icon='OPEN_RECENT', text="")
self.layout.menu('yyyt', icon='OPEN_RECENT', text="")
### アイテム
layout = self.layout
col = layout.column(align=True)
view = context.space_data
scene = context.scene
obj = context.object
# obj_type = obj.type
ob = context.active_object
row = layout.row()
row.template_ID(context.scene.objects, "active")
# row.label(text="", icon='OBJECT_DATA')
# row.prop(ob, "name", text="")
if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
bone = context.active_bone
row = layout.row()
row.label(text="", icon='BONE_DATA')
row.prop(bone, "name", text="")
# cam = bpy.context.scene.camera
# col = split.column()
# row = col.row()
# row.prop(cam, "lens")
# camx = bpy.context.scene.camera
# xxz = bpy.data.cameras["camx"]
layout.prop(context.object.data, "lens", text="lens")
# 連番リネーム
# row.prop(context.scene,"rno_str_new_name",text="")
# layout.operator("object.rno_setname",text="",icon='GREASEPENCIL')
st = context.space_data
toolsettings = context.tool_settings
row = layout.row(align=True)
row.template_header()
DOPESHEET_MT_editor_menus.draw_collapsible(context, layout)
layout.prop(st, "mode", text="")
if st.mode in {'ACTION', 'SHAPEKEY'}:
row = layout.row(align=True)
row.operator("action.layer_prev", text="", icon='TRIA_DOWN')
row.operator("action.layer_next", text="", icon='TRIA_UP')
layout.template_ID(st, "action", new="action.new", unlink="action.unlink")
row = layout.row(align=True)
row.operator("action.push_down", text="Push Down", icon='NLA_PUSHDOWN')
row.operator("action.stash", text="Stash", icon='FREEZE')
layout.prop(st.dopesheet, "show_summary", text="Summary")
if st.mode == 'DOPESHEET':
dopesheet_filter(layout, context)
elif st.mode == 'ACTION':
# 'genericFiltersOnly' limits the options to only the relevant 'generic' subset of
# filters which will work here and are useful (especially for character animation)
dopesheet_filter(layout, context, genericFiltersOnly=True)
elif st.mode == 'GPENCIL':
row = layout.row(align=True)
row.prop(st.dopesheet, "show_gpencil_3d_only", text="Active Only")
if st.dopesheet.show_gpencil_3d_only:
row = layout.row(align=True)
row.prop(st.dopesheet, "show_only_selected", text="")
row.prop(st.dopesheet, "show_hidden", text="")
row = layout.row(align=True)
row.prop(st.dopesheet, "use_filter_text", text="")
if st.dopesheet.use_filter_text:
row.prop(st.dopesheet, "filter_text", text="")
row.prop(st.dopesheet, "use_multi_word_filter", text="")
row = layout.row(align=True)
row.prop(toolsettings, "use_proportional_action",
text="", icon_only=True)
if toolsettings.use_proportional_action:
row.prop(toolsettings, "proportional_edit_falloff",
text="", icon_only=True)
# Grease Pencil mode doesn't need snapping, as it's frame-aligned only
if st.mode != 'GPENCIL':
layout.prop(st, "auto_snap", text="")
row = layout.row(align=True)
row.operator("action.copy", text="", icon='COPYDOWN')
row.operator("action.paste", text="", icon='PASTEDOWN')
if st.mode not in ('GPENCIL', 'MASK'):
row.operator("action.paste", text="", icon='PASTEFLIPDOWN').flipped = True
obj = context.object
obj_name = obj.name
for group in bpy.data.groups:
group_objects = group.objects
if obj_name in group.objects and obj in group_objects[:]:
col = layout.column(align=True)
col.context_pointer_set("group", group)
row.menu("GROUP_MT_specials_x", icon='META_CUBE', text="")
# row.prop(group, "name", text="")
# row.operator("object.group_remove", text="", icon='X', emboss=False)
class GROUP_MT_specials_x(bpy.types.Menu):
bl_label = "Group Specials"
def draw(self, context):
layout = self.layout
# row.prop(group, "name", text="")
obj = context.object
obj_name = obj.name
for group in bpy.data.groups:
group_objects = group.objects
if obj_name in group.objects and obj in group_objects[:]:
col = layout.column(align=True)
layout.prop(group, "name", text="")
# layout.operator("object.group_remove", icon='X', emboss=False)
# layout.operator("object.group_unlink", icon='X')
# layout.operator("object.grouped_select")
# layout.operator("object.dupli_offset_from_cursor")
# layout.operator("object.group_remove", icon='X', emboss=False)
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_HT_header.prepend(info_header_menu_x)
bpy.types.VIEW3D_MT_editor_menus.prepend(veiw3d_header_menu_x)
# bpy.types.VIEW3D_MT_editor_menus.prepend(header_color_change)
bpy.types.VIEW3D_HT_header.prepend(veiw3d_header_menu_x)
bpy.app.translations.register(__name__, translation_dict) # 辞書の登録
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_HT_header.remove(info_header_menu_x)
# bpy.types.INFO_HT_header.remove(header_color_change)
bpy.types.VIEW3D_MT_editor_menus.remove(veiw3d_header_menu_x)
bpy.types.VIEW3D_HT_header.remove(veiw3d_header_menu_x)
bpy.app.translations.unregister(__name__) # 辞書の削除
if __name__ == '__main__':
register()