Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/shading.py
Last active January 20, 2016 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/6a12c5432d9ea41e9eb2 to your computer and use it in GitHub Desktop.
Save zeffii/6a12c5432d9ea41e9eb2 to your computer and use it in GitHub Desktop.
shading menu for with objects and without objects
class PieRMB(Menu):
bl_idname = "pie.shadingview"
bl_label = "Viewport Shading "
def draw(self, context):
layout = self.layout
obj = context.object
pie = layout.menu_pie()
scene = context.scene
view = context.space_data
#4 - LEFT
f = pie.operator("wm.context_set_enum", icon='WIRE', text='Wires')
f.data_path='space_data.viewport_shade'
f.value = 'WIREFRAME'
#6 - RIGHT
pie.operator("object.hide_view_clear", text="Show Object")
#2 - BOTTOM
box = pie.split().box().column()
row = box.row()
box.operator("OBJECT_OT_shade_smooth", text="Object Smooth")
row = box.row()
box.operator("OBJECT_OT_shade_flat", text="Object Flat")
box.separator()
box.operator("calculate.normal", text="Calculate Normals")
box.separator()
row = box.row()
if obj:
mesh = obj.data
row.prop(mesh, "use_auto_smooth")
row = box.row()
row.prop(mesh, "auto_smooth_angle", text="Angle")
box.separator()
box.prop(view, "use_matcap")
box.template_icon_view(view, "matcap_icon")
#8 - TOP
f = pie.operator("wm.context_set_enum", icon='SMOOTH', text='Rendered')
f.data_path='space_data.viewport_shade'
f.value = 'RENDERED'
#7 - TOP - LEFT
f = pie.operator("wm.context_set_enum", icon='SOLID', text='Solid')
f.data_path='space_data.viewport_shade'
f.value = 'SOLID'
#9 - TOP - RIGHT
f = pie.operator("wm.context_set_enum", icon='MATERIAL', text='Material')
f.data_path='space_data.viewport_shade'
f.value = 'MATERIAL'
#1 - BOTTOM - LEFT
pie.operator("object.hide_view_set", text="Hide Object Selected").unselected=False
#3 - BOTTOM - RIGHT
pie.operator("object.hide_view_set", text="Hide Object Unselected").unselected=True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment