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
|
# ##### 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 #####
# Contributed to by: meta-androcto, JayDez, sim88, sam, lijenstina, mkb, wisaac, CoDEmanX #
import bpy
from bpy.types import (
Operator,
Menu,
)
from bpy.props import (
BoolProperty,
StringProperty,
)
# View Menu's #
# Display Wire (Thanks to marvin.k.breuer) #
class VIEW3D_OT_Display_Wire_All(Operator):
bl_label = "Wire on All Objects"
bl_idname = "view3d.display_wire_all"
bl_description = "Enable/Disable Display Wire on All Objects"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
is_error = False
for obj in bpy.data.objects:
try:
if obj.show_wire:
obj.show_all_edges = False
obj.show_wire = False
else:
obj.show_all_edges = True
obj.show_wire = True
except:
is_error = True
pass
if is_error:
self.report({'WARNING'},
"Wire on All Objects could not be completed for some objects")
return {'FINISHED'}
# Matcap and AO, Wire all and X-Ray entries thanks to marvin.k.breuer
class VIEW3D_MT_Shade(Menu):
bl_label = "Shade"
def draw(self, context):
layout = self.layout
# layout.prop(context.space_data, "viewport_shade", expand=True)
if context.active_object:
if(context.mode == 'EDIT_MESH'):
layout.operator("MESH_OT_faces_shade_smooth", icon='SHADING_RENDERED')
layout.operator("MESH_OT_faces_shade_flat", icon='SHADING_SOLID')
else:
layout.operator("OBJECT_OT_shade_smooth", icon='SHADING_RENDERED')
layout.operator("OBJECT_OT_shade_flat", icon='SHADING_SOLID')
layout.separator()
layout.operator("view3d.display_wire_all", text="Wire all", icon='SHADING_WIRE')
layout.separator()
layout.prop(context.space_data.fx_settings, "use_ssao",
text="Ambient Occlusion", icon="GROUP")
# layout.prop(context.space_data, "use_matcap", icon="MATCAP_01")
# if context.space_data.use_matcap:
# row = layout.column(1)
# row.scale_y = 0.3
# row.scale_x = 0.5
# row.template_icon_view(context.space_data, "matcap_icon")
def menu_func(self, context):
self.layout.menu("VIEW3D_MT_Shade")
# List The Classes #
classes = (
VIEW3D_MT_Shade,
VIEW3D_OT_Display_Wire_All,
)
# Register Classes & Hotkeys #
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.VIEW3D_MT_view.append(menu_func)
# Unregister Classes & Hotkeys #
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)
bpy.types.VIEW3D_MT_view.remove(menu_func)
if __name__ == "__main__":
register()
|