forked from pitiwazou/Scripts-Blender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWazou_Popup_Shading_Menu
273 lines (193 loc) · 8.2 KB
/
Wazou_Popup_Shading_Menu
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
# ##### 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 #####
bl_info = {
"name": "Wazou_Custom_Menu",
"category": "3D View",
"author": "Cedric_Lepiller & PID"
}
import bpy
#auto smooth Menu
class AutoSmoothMenu(bpy.types.Menu):
bl_idname = "auto.smooth_menu"
bl_label = "Auto_Smooth_Menu"
def draw(self, context):
layout = self.layout
layout.operator("auto.smooth_30", text="Auto Smooth 30", icon='MESH_DATA')
layout.operator("auto.smooth_45", text="Auto Smooth 45", icon='MESH_DATA')
layout.operator("auto.smooth_89", text="Auto Smooth 89", icon='MESH_DATA')
bpy.utils.register_class(AutoSmoothMenu)
#AutoSmooth_89
class AutoSmooth89(bpy.types.Operator):
bl_idname = "auto.smooth_89"
bl_label = "Auto Smooth"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
bpy.context.object.data.auto_smooth_angle = 1.55334
return {'FINISHED'}
bpy.utils.register_class(AutoSmooth89)
#AutoSmooth_30
class AutoSmooth30(bpy.types.Operator):
bl_idname = "auto.smooth_30"
bl_label = "Auto Smooth"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
bpy.context.object.data.auto_smooth_angle = 0.523599
return {'FINISHED'}
bpy.utils.register_class(AutoSmooth30)
#AutoSmooth_45
class AutoSmooth45(bpy.types.Operator):
bl_idname = "auto.smooth_45"
bl_label = "Auto Smooth"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
bpy.context.object.data.auto_smooth_angle = 0.785398
return {'FINISHED'}
bpy.utils.register_class(AutoSmooth45)
#Solid All
class SolidAll(bpy.types.Operator):
bl_idname = "object.solid_all"
bl_label = "Solid All"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
for obj in bpy.data.objects:
if obj.draw_type == 'BOUNDS':
obj.draw_type = 'SOLID'
elif obj.draw_type == 'SOLID':
obj.draw_type = 'SOLID'
else:
obj.draw_type = 'BOUNDS'
return {'FINISHED'}
bpy.utils.register_class(SolidAll)
#Bounds Unselected
class BoundsUnselected(bpy.types.Operator):
bl_idname = "object.draw_bu"
bl_label = "bounds"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
for obj in bpy.data.objects:
if not obj.select:
if obj.draw_type == 'SOLID':
obj.draw_type = 'BOUNDS'
obj.show_all_edges = False
obj.show_wire = False
elif obj.draw_type == 'BOUNDS':
obj.draw_type = 'BOUNDS'
else:
obj.draw_type = 'SOLID'
for obj in bpy.data.objects:
if obj.select:
obj.draw_type = 'SOLID'
return {'FINISHED'}
bpy.utils.register_class(BoundsUnselected)
#Wire on selected objects
class WireSelected(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.wire_selected"
bl_label = "Wire Selected"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
for obj in bpy.data.objects:
if obj.select:
if obj.show_wire:
obj.show_all_edges = False
obj.show_wire = False
else:
obj.show_all_edges = True
obj.show_wire = True
return {'FINISHED'}
bpy.utils.register_class(WireSelected)
#Wire on all objects
class Wire_All(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.wire_all"
bl_label = "Wire on All Objects"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
for obj in bpy.data.objects:
if obj.show_wire:
obj.show_all_edges = False
obj.show_wire = False
else:
obj.show_all_edges = True
obj.show_wire = True
return {'FINISHED'}
bpy.utils.register_class(Wire_All)
#Grid show/hide with axes
class ToogleGridAxis(bpy.types.Operator):
"""Tooltip"""
bl_idname = "scene.tooglegridaxis"
bl_label = "Toogle Grid and Axis in 3D view"
@classmethod
def poll(cls, context):
return context.active_object is not None
def execute(self, context):
bpy.context.space_data.show_axis_y = not bpy.context.space_data.show_axis_y
bpy.context.space_data.show_axis_x = not bpy.context.space_data.show_axis_x
bpy.context.space_data.show_floor = not bpy.context.space_data.show_floor
return {'FINISHED'}
bpy.utils.register_class(ToogleGridAxis)
class customMenu(bpy.types.Menu):
bl_label = ""
bl_idname = "View3D.wazoucustomMenu"
# Set the menu operators and draw functions
def draw(self, context):
layout = self.layout
#Wire block
layout.operator("object.wire_all", text="Wire All", icon='WIRE')
layout.operator("object.wire_selected", text="Wire Selected", icon='WIRE')
layout.separator()
layout.operator("object.shade_smooth", icon = 'ANTIALIASED')
layout.operator("object.shade_flat", icon = 'ALIASED')
layout.separator()
layout.operator("wm.context_toggle", text="Xray", icon='META_CUBE').data_path = "object.show_x_ray"
layout.operator("wm.context_toggle", text="Hidden Wire", icon='GHOST_ENABLED').data_path = "space_data.show_occlude_wire"
layout.operator("wm.context_toggle", text="Limit 2 Visible", icon='ORTHO').data_path = "space_data.use_occlude_geometry"
layout.separator()
layout.operator("object.draw_bu", text="Bounds Unselected", icon='GROUP_VERTEX')
layout.operator("object.solid_all", text="Solid All", icon='MESH_CUBE')
layout.separator()
#Cam block
layout.operator("wm.context_toggle", text="Only Render", icon='SOLID').data_path = "space_data.show_only_render"
layout.operator("wm.context_toggle", text="Lock Cam 2 view", icon='OUTLINER_DATA_CAMERA').data_path = "space_data.lock_camera"
layout.operator("wm.context_toggle", text="Matcaps", icon='MATCAP_02').data_path = "space_data.use_matcap"
layout.operator("scene.tooglegridaxis", text="Show/Hide Grid", icon="MESH_GRID")
layout.separator()
#Normals block
layout.operator("wm.context_toggle", text="Auto Smooth", icon='MESH_DATA').data_path = "object.data.use_auto_smooth"
layout.menu("auto.smooth_menu", text="Auto Smooth Values", icon='MESH_DATA')
layout.operator("wm.context_toggle", text="Show Normals", icon='FACESEL').data_path = "object.data.show_normal_face"
def register():
bpy.utils.register_class(customMenu)
bpy.ops.wm.call_menu(name=customMenu.bl_idname)
def unregister():
bpy.utils.unregister_class(customMenu)
if __name__ == "__main__": register()