def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
#4 - LEFT
pie.operator("snap.vertex", text="Vertex", icon='SNAP_VERTEX')
#6 - RIGHT
pie.operator("snap.face", text="Face", icon='SNAP_FACE')
#2 - BOTTOM
pie.operator("snap.edge", text="Edge", icon='SNAP_EDGE')
#8 - TOP
pie.prop(context.tool_settings, "use_snap", text="Snap On/Off")
#7 - TOP - LEFT
pie.operator("snap.volume", text="Volume", icon='SNAP_VOLUME')
#9 - TOP - RIGHT
if bpy.context.scene.tool_settings.snap_element != 'INCREMENT':
pie.operator("snap.increment", text="Increment", icon='SNAP_INCREMENT')
else:
pie.prop(context.scene.tool_settings, "use_snap_grid_absolute")
#1 - BOTTOM - LEFT
pie.operator("snap.alignrotation", text="Align rotation", icon='SNAP_NORMAL')
#3 - BOTTOM - RIGHT
pie.operator("wm.call_menu_pie", text="Snap Target", icon='SNAP_SURFACE').name="snap.targetmenu"
#Menu Snap Target - Shift + Tab
python类Menu()的实例源码
def draw(self, context):
menu = utils_core.Menu(self)
path = "tool_settings.image_paint.brush.mask_texture_slot.mask_map_mode"
has_brush = utils_core.get_brush_link(context, types="brush")
menu.add_item().label(text="Mask Mapping")
menu.add_item().separator()
if has_brush:
items = has_brush. \
mask_texture_slot.bl_rna.properties['mask_map_mode'].enum_items
# add the menu items
for item in items:
utils_core.menuprop(
menu.add_item(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
menu.add_item().label("No brushes available", icon="INFO")
def draw(self, context):
brush, path = self.init()
menu = utils_core.Menu(self)
menu.add_item().label(text="Stroke Method")
menu.add_item().separator()
if brush:
# add the menu items dynamicaly based on values in enum property
for tool in brush.bl_rna.properties['stroke_method'].enum_items:
if tool.identifier in [anchored, drag_dot] and \
utils_core.get_mode() in [utils_core.vertex_paint,
utils_core.weight_paint]:
continue
utils_core.menuprop(
menu.add_item(), tool.name, tool.identifier, path,
icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON'
)
else:
menu.add_item().label("No Stroke Method available", icon="INFO")
def draw(self, context):
settings, datapath, slider_setting = self.init()
menu = utils_core.Menu(self)
# add the top slider
menu.add_item().prop(context.tool_settings.sculpt,
slider_setting, slider=True)
menu.add_item().separator()
# add the rest of the menu items
for i in range(len(settings)):
utils_core.menuprop(
menu.add_item(), settings[i][0], settings[i][1], datapath,
icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON'
)
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("object.select_by_layer", text="Select By Layer", icon='LAYER_ACTIVE')
# 6 - RIGHT
pie.operator("object.select_random", text="Select Random", icon='GROUP_VERTEX')
# 2 - BOTTOM
pie.operator("object.select_all", text="Invert Selection",
icon='ZOOM_PREVIOUS').action = 'INVERT'
# 8 - TOP
pie.operator("object.select_all", text="Select All Toggle",
icon='RENDER_REGION').action = 'TOGGLE'
# 7 - TOP - LEFT
pie.operator("view3d.select_circle", text="Circle Select", icon='BORDER_LASSO')
# 9 - TOP - RIGHT
pie.operator("view3d.select_border", text="Border Select", icon='BORDER_RECT')
# 1 - BOTTOM - LEFT
pie.operator("object.select_camera", text="Select Camera", icon='CAMERA_DATA')
# 3 - BOTTOM - RIGHT
pie.menu("pie.selectionsmore", text="Select Menu", icon='RESTRICT_SELECT_OFF')
# Pie Selection Edit Mode
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
#4 - LEFT
pie.operator("snap.vertex", text="Vertex", icon='SNAP_VERTEX')
#6 - RIGHT
pie.operator("snap.face", text="Face", icon='SNAP_FACE')
#2 - BOTTOM
pie.operator("snap.edge", text="Edge", icon='SNAP_EDGE')
#8 - TOP
pie.prop(context.tool_settings, "use_snap", text="Snap On/Off")
#7 - TOP - LEFT
pie.operator("snap.volume", text="Volume", icon='SNAP_VOLUME')
#9 - TOP - RIGHT
pie.operator("snap.increment", text="Increment", icon='SNAP_INCREMENT')
#1 - BOTTOM - LEFT
pie.operator("snap.alignrotation", text="Align rotation", icon='SNAP_NORMAL')
#3 - BOTTOM - RIGHT
pie.operator("wm.call_menu_pie", text="Snap Target", icon='SNAP_SURFACE').name="snap.targetmenu"
#Menu Snap Target - Shift + Tab
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
#4 - LEFT
pie.operator("uv.align", text="Align X").axis = 'ALIGN_X'
#6 - RIGHT
pie.operator("uv.align", text="Align Y").axis = 'ALIGN_Y'
#2 - BOTTOM
pie.operator("uv.align", text="Straighten").axis = 'ALIGN_S'
#8 - TOP
pie.operator("uv.align", text="Align Auto").axis = 'ALIGN_AUTO'
#7 - TOP - LEFT
pie.operator("uv.weld", text="Weld", icon='AUTOMERGE_ON')
#9 - TOP - RIGHT
pie.operator("uv.remove_doubles", text="Remouve doubles")
#1 - BOTTOM - LEFT
pie.operator("uv.align", text="Straighten X").axis = 'ALIGN_T'
#3 - BOTTOM - RIGHT
pie.operator("uv.align", text="Straighten Y").axis = 'ALIGN_U'
#Pie Texture Paint Pie Menu - W
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
#4 - LEFT
pie.operator("snap.vertex", text="Vertex", icon='SNAP_VERTEX')
#6 - RIGHT
pie.operator("snap.face", text="Face", icon='SNAP_FACE')
#2 - BOTTOM
pie.operator("wm.context_toggle", text="Auto Merge", icon='AUTOMERGE_ON').data_path = "scene.tool_settings.use_mesh_automerge"
#8 - TOP
pie.prop(context.tool_settings, "use_snap", text="Snap On/Off")
#7 - TOP - LEFT
pie.operator("snap.volume", text="Volume", icon='SNAP_VOLUME')
#9 - TOP - RIGHT
pie.operator("snap.increment", text="Increment", icon='SNAP_INCREMENT')
#1 - BOTTOM - LEFT
pie.operator("snap.alignrotation", text="Align rotation", icon='SNAP_NORMAL')
#3 - BOTTOM - RIGHT
pie.operator("wm.call_menu_pie", text="Snap Target", icon='SNAP_SURFACE').name="snap.targetmenu"
#Menu Snap Target - Shift + Tab
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
#4 - LEFT
pie.operator("uv.align", text="Align X").axis = 'ALIGN_X'
#6 - RIGHT
pie.operator("uv.align", text="Align Y").axis = 'ALIGN_Y'
#2 - BOTTOM
pie.operator("uv.align", text="Straighten").axis = 'ALIGN_S'
#8 - TOP
pie.operator("uv.align", text="Align Auto").axis = 'ALIGN_AUTO'
#7 - TOP - LEFT
pie.operator("uv.weld", text="Weld", icon='AUTOMERGE_ON')
#9 - TOP - RIGHT
pie.operator("uv.remove_doubles", text="Remouve doubles")
#1 - BOTTOM - LEFT
pie.operator("uv.align", text="Straighten X").axis = 'ALIGN_T'
#3 - BOTTOM - RIGHT
pie.operator("uv.align", text="Straighten Y").axis = 'ALIGN_U'
#Pie Texture Paint Pie Menu - W
def draw(self, context):
layout = self.layout
col = layout.column(align=True)
col.operator(
"scene.export_animations",
text="Export Animations",
icon="RENDER_ANIMATION")
col.separator()
col.operator(
"scene.export_to_game",
text="Export to CryEngine",
icon_value=bcry_icons["crye"].icon_id)
col.separator()
#------------------------------------------------------------------------------
# BCry Exporter Menu:
#------------------------------------------------------------------------------
def draw(self, context):
menu = utils_core.Menu(self)
if utils_core.get_mode() == utils_core.sculpt:
self.sculpt(menu, context)
elif utils_core.get_mode() == utils_core.vertex_paint:
self.vertpaint(menu, context)
else:
self.texpaint(menu, context)
def draw(self, context):
datapath = self.init()
has_brush = utils_core.get_brush_link(context, types="brush")
current_texture = eval("bpy.context.{}".format(datapath)) if \
has_brush else None
menu = utils_core.Menu(self)
# get the current texture's name
if current_texture:
current_texture = current_texture.name
menu.add_item().label(text="Brush Texture")
menu.add_item().separator()
# add an item to set the texture to None
utils_core.menuprop(menu.add_item(), "None", "None",
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=[None, current_texture],
path=True)
# add the menu items
for item in bpy.data.textures:
utils_core.menuprop(menu.add_item(), item.name,
'bpy.data.textures["%s"]' % item.name,
datapath, icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=[item.name, current_texture],
path=True)
def draw(self, context):
menu = utils_core.Menu(self)
datapath = "tool_settings.image_paint.brush.mask_texture"
has_brush = utils_core.get_brush_link(context, types="brush")
current_texture = eval("bpy.context.{}".format(datapath)) if \
has_brush else None
menu.add_item().label(text="Mask Texture")
menu.add_item().separator()
if has_brush:
# get the current texture's name
if current_texture:
current_texture = current_texture.name
# add an item to set the texture to None
utils_core.menuprop(
menu.add_item(), "None", "None",
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=[None, current_texture],
path=True
)
# add the menu items
for item in bpy.data.textures:
utils_core.menuprop(
menu.add_item(), item.name, 'bpy.data.textures["%s"]' % item.name,
datapath, icon='RADIOBUT_OFF', disable=True,
disable_icon='RADIOBUT_ON',
custom_disable_exp=[item.name, current_texture],
path=True
)
else:
menu.add_item().label("No brushes available", icon="INFO")
def draw(self, context):
menu = utils_core.Menu(self)
if context.object.use_dynamic_topology_sculpting:
menu.add_item().operator("sculpt.dynamic_topology_toggle",
"Disable Dynamic Topology")
menu.add_item().separator()
menu.add_item().menu(DynDetailMenu.bl_idname)
menu.add_item().menu(DetailMethodMenu.bl_idname)
menu.add_item().separator()
menu.add_item().operator("sculpt.optimize")
if context.tool_settings.sculpt.detail_type_method == 'CONSTANT':
menu.add_item().operator("sculpt.detail_flood_fill")
menu.add_item().menu(SymmetrizeMenu.bl_idname)
menu.add_item().prop(context.tool_settings.sculpt,
"use_smooth_shading", toggle=True)
else:
menu.add_item()
menu.current_item.operator_context = 'INVOKE_DEFAULT'
menu.current_item.operator("sculpt.dynamic_topology_toggle",
"Enable Dynamic Topology")
def draw(self, context):
menu = utils_core.Menu(self)
refine_path = "tool_settings.sculpt.detail_refine_method"
type_path = "tool_settings.sculpt.detail_type_method"
refine_items = [["Subdivide Edges", 'SUBDIVIDE'],
["Collapse Edges", 'COLLAPSE'],
["Subdivide Collapse", 'SUBDIVIDE_COLLAPSE']]
type_items = [["Relative Detail", 'RELATIVE'],
["Constant Detail", 'CONSTANT']]
menu.add_item().label("Refine")
menu.add_item().separator()
# add the refine menu items
for item in refine_items:
utils_core.menuprop(
menu.add_item(), item[0], item[1],
refine_path, disable=True,
icon='RADIOBUT_OFF',
disable_icon='RADIOBUT_ON'
)
menu.add_item().label("")
menu.add_item().label("Type")
menu.add_item().separator()
# add the type menu items
for item in type_items:
utils_core.menuprop(
menu.add_item(), item[0], item[1],
type_path, disable=True,
icon='RADIOBUT_OFF', disable_icon='RADIOBUT_ON'
)
def draw(self, context):
menu = utils_core.Menu(self)
if utils_core.get_mode() == utils_core.texture_paint:
menu.add_item().prop(context.tool_settings.image_paint,
"use_symmetry_x", toggle=True)
menu.add_item().prop(context.tool_settings.image_paint,
"use_symmetry_y", toggle=True)
menu.add_item().prop(context.tool_settings.image_paint,
"use_symmetry_z", toggle=True)
else:
menu.add_item().menu(SymmetryMenu.bl_idname)
menu.add_item().menu(SymmetryRadialMenu.bl_idname)
menu.add_item().prop(context.tool_settings.sculpt,
"use_symmetry_feather", toggle=True)
def draw(self, context):
menu = utils_core.Menu(self)
menu.add_item().label(text="Symmetry")
menu.add_item().separator()
menu.add_item().prop(context.tool_settings.sculpt,
"use_symmetry_x", toggle=True)
menu.add_item().prop(context.tool_settings.sculpt,
"use_symmetry_y", toggle=True)
menu.add_item().prop(context.tool_settings.sculpt,
"use_symmetry_z", toggle=True)
def draw(self, context):
menu = utils_core.Menu(self)
menu.add_item().label(text="Radial")
menu.add_item().separator()
menu.add_item("column").prop(context.tool_settings.sculpt,
"radial_symmetry", text="", slider=True)
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("view3d.select_border", text="Border Select",
icon='BORDER_RECT')
# 6 - RIGHT
pie.menu("object.selectloopselection", text="Select Loop Menu", icon='LOOPSEL')
# 2 - BOTTOM
pie.operator("mesh.select_all", text="Select None",
icon='RESTRICT_SELECT_ON').action = 'DESELECT'
# 8 - TOP
pie.operator("mesh.select_all", text="Select All",
icon='RESTRICT_SELECT_OFF').action = 'SELECT'
# 7 - TOP - LEFT
pie.operator("mesh.select_all", text="Select All Toggle",
icon='ARROW_LEFTRIGHT').action = 'TOGGLE'
# 9 - TOP - RIGHT
pie.operator("mesh.select_all", text="Invert Selection",
icon='FULLSCREEN_EXIT').action = 'INVERT'
# 1 - BOTTOM - LEFT
pie.operator("view3d.select_circle", text="Circle Select",
icon='BORDER_LASSO')
# 3 - BOTTOM - RIGHT
pie.menu("object.selectallbyselection", text="Multi Select Menu", icon='SNAP_EDGE')
# Select All By Selection
def execute(self, context):
origin_to_geometry(context)
return {'FINISHED'}
#Menu Snap Target
def execute(self, context):
bpy.context.scene.tool_settings.snap_element=self.variable
return {'FINISHED'}
#Menu Snap Element
def draw(self, context):
settings = bpy.context.scene.tool_settings
layout = self.layout
pie = layout.menu_pie()
pie.prop(settings, "snap_element", expand=True)
#Menu Snap Element
def draw(self, context):
menu = utils_core.Menu(self)
has_brush = utils_core.get_brush_link(context, types="brush")
menu.add_item().label(text="Brush Mapping")
menu.add_item().separator()
if has_brush:
if utils_core.get_mode() == utils_core.sculpt:
path = "tool_settings.sculpt.brush.texture_slot.map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['map_mode'].enum_items:
utils_core.menuprop(
menu.add_item(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
elif utils_core.get_mode() == utils_core.vertex_paint:
path = "tool_settings.vertex_paint.brush.texture_slot.tex_paint_map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['tex_paint_map_mode'].enum_items:
utils_core.menuprop(
menu.add_item(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
path = "tool_settings.image_paint.brush.texture_slot.tex_paint_map_mode"
# add the menu items
for item in has_brush. \
texture_slot.bl_rna.properties['tex_paint_map_mode'].enum_items:
utils_core.menuprop(
menu.add_item(), item.name, item.identifier, path,
icon='RADIOBUT_OFF',
disable=True,
disable_icon='RADIOBUT_ON'
)
else:
menu.add_item().label("No brushes available", icon="INFO")
def draw(self, context):
settings, brush, stroke_method = self.init()
menu = utils_core.Menu(self)
menu.add_item().menu(StrokeMethodMenu.bl_idname)
menu.add_item().separator()
if stroke_method:
if stroke_method == space and brush:
menu.add_item().prop(brush, "spacing",
text=utils_core.PIW + "Spacing", slider=True)
elif stroke_method == airbrush and brush:
menu.add_item().prop(brush, "rate",
text=utils_core.PIW + "Rate", slider=True)
elif stroke_method == anchored and brush:
menu.add_item().prop(brush, "use_edge_to_edge")
else:
pass
if utils_core.get_mode() == utils_core.sculpt and stroke_method in (drag_dot, anchored):
pass
else:
if brush:
menu.add_item().prop(brush, "jitter",
text=utils_core.PIW + "Jitter", slider=True)
menu.add_item().prop(settings, "input_samples",
text=utils_core.PIW + "Input Samples", slider=True)
if stroke_method in [dots, space, airbrush] and brush:
menu.add_item().separator()
menu.add_item().prop(brush, "use_smooth_stroke", toggle=True)
if brush.use_smooth_stroke:
menu.add_item().prop(brush, "smooth_stroke_radius",
text=utils_core.PIW + "Radius", slider=True)
menu.add_item().prop(brush, "smooth_stroke_factor",
text=utils_core.PIW + "Factor", slider=True)
else:
menu.add_item().label("No Stroke Options available", icon="INFO")
def register():
# Poly Pie_void
bpy.utils.register_class(PiePoly)
bpy.utils.register_class(PieObject)
bpy.utils.register_class(PieSculpt)
bpy.utils.register_class(PieVertexPaint)
bpy.utils.register_class(PieWeightPaint)
bpy.utils.register_class(PieTexturePaint)
bpy.utils.register_class(ParticleNone)
bpy.utils.register_class(ParticleComb)
bpy.utils.register_class(ParticleSmooth)
bpy.utils.register_class(ParticleAdd)
bpy.utils.register_class(ParticleLength)
bpy.utils.register_class(ParticlePuff)
bpy.utils.register_class(ParticleCut)
bpy.utils.register_class(ParticleWeight)
bpy.utils.register_class(ParticleEdit)
# Keympa Config
wm = bpy.context.window_manager
if wm.keyconfigs.addon:
#Poly Pie
km = wm.keyconfigs.addon.keymaps.new(name='Mesh')
kmi = km.keymap_items.new('wm.call_menu_pie', 'MIDDLEMOUSE', 'PRESS', shift=True)
kmi.properties.name = "poly.pie"
#Object Pie
km = wm.keyconfigs.addon.keymaps.new(name='Object Mode')
kmi = km.keymap_items.new('wm.call_menu_pie', 'MIDDLEMOUSE', 'PRESS', shift=True)
kmi.properties.name = "object.pie"
#Sculpt Pie Menu
km = wm.keyconfigs.addon.keymaps.new(name='Sculpt')
kmi = km.keymap_items.new('wm.call_menu_pie', 'MIDDLEMOUSE', 'PRESS', shift=True)
kmi.properties.name = "sculpt.pie"
#Vertex Paint Pie Menu
km = wm.keyconfigs.addon.keymaps.new(name='Vertex Paint')
kmi = km.keymap_items.new('wm.call_menu_pie', 'MIDDLEMOUSE', 'PRESS', shift=True)
kmi.properties.name = "vpaint.pie"
#Weight Paint Pie Menu
km = wm.keyconfigs.addon.keymaps.new(name='Weight Paint')
kmi = km.keymap_items.new('wm.call_menu_pie', 'MIDDLEMOUSE', 'PRESS', shift=True)
kmi.properties.name = "wpaint.pie"
#Texture Paint Pie Menu
km = wm.keyconfigs.addon.keymaps.new(name='Image Paint')
kmi = km.keymap_items.new('wm.call_menu_pie', 'MIDDLEMOUSE', 'PRESS', shift=True)
kmi.properties.name = "tpaint.pie"
#Particle Edit Pie Menu
km = wm.keyconfigs.addon.keymaps.new(name='Particle')
kmi = km.keymap_items.new('wm.call_menu_pie', 'MIDDLEMOUSE', 'PRESS', shift=True)
kmi.properties.name = "particle_edit.pie"
# Register / Unregister Classes