Skip to content

Instantly share code, notes, and snippets.

@demohero101
Created October 9, 2022 12:31
Show Gist options
  • Save demohero101/9a6602650bbce925f56ced3604e3bfc3 to your computer and use it in GitHub Desktop.
Save demohero101/9a6602650bbce925f56ced3604e3bfc3 to your computer and use it in GitHub Desktop.
Pie Menu Ornek
import bpy
from bpy.types import Menu
class PIE_MT_AddMeshObjects(Menu):
bl_idname = "PIE_MT_add_mesh_objects"
bl_label = "Add Mesh Objects"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
# 4 - LEFT
pie.operator("mesh.primitive_plane_add", text = "Add Plane", icon = "MESH_PLANE")
# 6 - RIGHT
pie.operator("mesh.primitive_cube_add", text = "Add Cube", icon = "MESH_CUBE")
# 2 - BOTTOM
pie.operator("mesh.primitive_circle_add", text = "Add Circle", icon = "MESH_CIRCLE")
# 8 - TOP
pie.operator("mesh.primitive_uv_sphere_add", text = "Add UV Sphere", icon = "MESH_UVSPHERE")
# 7 - TOP - LEFT
pie.operator("mesh.primitive_ico_sphere_add", text = "Add Ico Sphere", icon = "MESH_ICOSPHERE")
# 9 - TOP - RIGHT
pie.operator("mesh.primitive_cylinder_add", text = "Add Cylinder", icon = "MESH_CYLINDER")
# 1 - BOTTOM - LEFT
pie.operator("mesh.primitive_cone_add", text = "Add Cone", icon = "MESH_CONE")
# 3 - BOTTOM - RIGHT
pie.operator("mesh.primitive_torus_add", text = "Add Torus", icon = "MESH_TORUS")
classes = (
PIE_MT_AddMeshObjects,
)
addon_keymaps = []
def register():
for cls in classes:
bpy.utils.register_class(cls)
wm = bpy.context.window_manager
if wm.keyconfigs.addon:
# Shading
km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS', ctrl=True, shift=False, alt=False)
kmi.properties.name = "PIE_MT_add_mesh_objects"
addon_keymaps.append((km, kmi))
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
if __name__ == "__main__":
register()
#bpy.ops.wm.call_menu_pie(name="PIE_MT_AddMeshObjects")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment