Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- from bpy.types import Menu
- from bpy.types import Operator
- bl_info = {
- "name": "Custom Add Mesh Pie Menu",
- "author": "Jake Mobley",
- "version": (1, 0),
- "blender": (2, 80, 0),
- "description": "Pie Menu to add a new Object",
- "warning": "Make sure Extra Objects and Extra Curve Objects are enabled ",
- "wiki_url": "",
- "category": "Add Mesh",
- }
- class ADD_MESH_MT_pie(Menu):
- bl_label = "Add Mesh"
- bl_idname = "ADD_MESH_MT_pie"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- # LEFT
- pie.menu("VIEW3D_MT_custom_cube_add", icon="MESH_CUBE", text= "Cube")
- # RIGHT
- pie.menu("VIEW3D_MT_cylinder_add")
- # Bottom
- pie.menu("VIEW3D_MT_custom_curve_add", icon="CURVE_DATA", text= "Curves")
- # TOP
- pie.menu("VIEW3D_MT_sphere_add")
- # 10:00
- pie.menu("VIEW3D_MT_circle_add", icon="MESH_CIRCLE", text = "Circle")
- # 2:00
- pie.menu("VIEW3D_MT_custom_plane_add", icon="MESH_PLANE", text= "Plane")
- # 7:00
- pie.menu("VIEW3D_MT_empty_add", icon="EMPTY_AXIS", text= "Empty")
- # 5:00
- pie.menu("VIEW3D_MT_custom_extras_add", icon="BRUSH_TEXFILL", text= "Extra Objects")
- class VIEW3D_MT_custom_cylinder_add(Menu):
- bl_idname = "VIEW3D_MT_cylinder_add"
- bl_label = "Cylinder"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-6").type = 'Cyl_6'
- col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-8").type = 'Cyl_8'
- col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-16").type = 'Cyl_16'
- col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-24").type = 'Cyl_24'
- col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-32").type = 'Cyl_32'
- col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-48").type = 'Cyl_48'
- col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-64").type = 'Cyl_64'
- class VIEW3D_MT_custom_circle_add(Menu):
- bl_idname = "VIEW3D_MT_circle_add"
- bl_label = "Circle"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-6").type = 'Circle_6'
- col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-8").type = 'Circle_8'
- col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-16").type = 'Circle_16'
- col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-24").type = 'Circle_24'
- col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-32").type = 'Circle_32'
- col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-48").type = 'Circle_48'
- col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-64").type = 'Circle_64'
- class VIEW3D_MT_custom_sphere_add(Menu):
- bl_idname = "VIEW3D_MT_sphere_add"
- bl_label = "Sphere"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Sphere-16").type = 'UV_16'
- col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Sphere-24").type = 'UV_24'
- col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Sphere-32").type = 'UV_32'
- col.operator("mesh.primitive_ico_sphere_add", icon="MESH_ICOSPHERE", text = "Icosphere")
- class VIEW3D_MT_custom_empty_add(Menu):
- bl_idname = "VIEW3D_MT_empty_add"
- bl_label = "Empty"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("view3d.add_cust_primitive", icon='EMPTY_AXIS', text = "Plain Axes").type = 'EMPTY_PL'
- col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Empty Sphere").type = 'EMPTY_SP'
- col.operator("view3d.add_cust_primitive", icon='MESH_CUBE', text = "Empty Cube").type = 'EMPTY_CU'
- col.operator("view3d.add_cust_primitive", icon='EMPTY_ARROWS', text = "Arrows").type = 'EMPTY_ARR'
- col.operator("import_image.to_plane", icon="IMAGE_DATA", text = "Image as Plane")
- class VIEW3D_MT_custom_cube_add(Menu):
- bl_idname = "VIEW3D_MT_custom_cube_add"
- bl_label = "Cube"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text = "Cube")
- col.operator("mesh.primitive_round_cube_add", icon='META_CUBE', text = "Round Cube")
- class VIEW3D_MT_custom_curve_add(Menu):
- bl_idname = "VIEW3D_MT_custom_curve_add"
- bl_label = "Curves"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("curve.primitive_bezier_curve_add", icon='CURVE_DATA', text = "Bezier")
- col.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text = "Path")
- col.operator("curve.primitive_bezier_circle_add", icon='CURVE_NCIRCLE', text = "Circle")
- col.operator("curve.spirals", icon='FORCE_VORTEX', text = "Spiral")
- class VIEW3D_MT_custom_plane_add(Menu):
- bl_idname = "VIEW3D_MT_custom_plane_add"
- bl_label = "Plane"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text = "Plane")
- col.operator("mesh.primitive_vert_add", icon='DOT', text = "Single Vertex")
- class VIEW3D_MT_custom_extras_add(Menu):
- bl_idname = "VIEW3D_MT_custom_extras_add"
- bl_label = "Plane"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- split = pie.split()
- col = split.column()
- col.operator("view3d.add_cust_primitive", icon='OUTLINER_OB_ARMATURE', text = "UE4 Mannequin").type = "MANNY"
- col.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text = "Torus")
- col.operator("mesh.primitive_cone_add", icon='MESH_CONE', text = "Cone")
- col.operator("view3d.add_cust_primitive", icon='LATTICE_DATA', text = "Lattice").type = "LATTICE"
- class VIEW3D_addprimitive(bpy.types.Operator):
- bl_idname = "view3d.add_cust_primitive"
- bl_label = "Add Primitive"
- bl_description = "Add Primitive"
- bl_options = {'REGISTER', 'UNDO'}
- type = bpy.props.StringProperty(name="Type")
- def invoke(self, context, event):
- def prim(self, type):
- if self.type == 'Cyl_6':
- bpy.ops.mesh.primitive_cylinder_add(vertices = 6)
- if self.type == 'Cyl_8':
- bpy.ops.mesh.primitive_cylinder_add(vertices=8)
- if self.type == 'Cyl_12':
- bpy.ops.mesh.primitive_cylinder_add(vertices=12)
- if self.type == 'Cyl_16':
- bpy.ops.mesh.primitive_cylinder_add(vertices=16)
- if self.type == 'Cyl_24':
- bpy.ops.mesh.primitive_cylinder_add(vertices=24)
- if self.type == 'Cyl_32':
- bpy.ops.mesh.primitive_cylinder_add(vertices=32)
- if self.type == 'Cyl_48':
- bpy.ops.mesh.primitive_cylinder_add(vertices=48)
- if self.type == 'Cyl_64':
- bpy.ops.mesh.primitive_cylinder_add(vertices=64)
- if self.type == 'Circle_6':
- bpy.ops.mesh.primitive_circle_add(vertices = 6)
- if self.type == 'Circle_8':
- bpy.ops.mesh.primitive_circle_add(vertices=8)
- if self.type == 'Circle_12':
- bpy.ops.mesh.primitive_circle_add(vertices=12)
- if self.type == 'Circle_16':
- bpy.ops.mesh.primitive_circle_add(vertices=16)
- if self.type == 'Circle_24':
- bpy.ops.mesh.primitive_circle_add(vertices=24)
- if self.type == 'Circle_32':
- bpy.ops.mesh.primitive_circle_add(vertices=32)
- if self.type == 'Circle_48':
- bpy.ops.mesh.primitive_circle_add(vertices=48)
- if self.type == 'Circle_64':
- bpy.ops.mesh.primitive_circle_add(vertices=64)
- if self.type == 'UV_16':
- bpy.ops.mesh.primitive_uv_sphere_add(segments=16, ring_count=8)
- if self.type == 'UV_24':
- bpy.ops.mesh.primitive_uv_sphere_add(segments=24, ring_count=12)
- if self.type == 'UV_32':
- bpy.ops.mesh.primitive_uv_sphere_add(segments=32, ring_count=16)
- if self.type == 'EMPTY_PL':
- bpy.ops.object.empty_add(type='PLAIN_AXES')
- if self.type == 'EMPTY_SP':
- bpy.ops.object.empty_add(type='SPHERE')
- if self.type == 'EMPTY_CU':
- bpy.ops.object.empty_add(type='CUBE')
- if self.type == 'EMPTY_ARR':
- bpy.ops.object.empty_add(type='ARROWS')
- if self.type == 'LATTICE':
- bpy.ops.object.add(type='LATTICE')
- if self.type == 'MANNY':
- bpy.ops.object.collection_instance_add(collection='mannequin_ref')
- prim(self, type)
- return {'FINISHED'}
- classes = (
- VIEW3D_addprimitive,
- VIEW3D_MT_custom_cylinder_add,
- VIEW3D_MT_custom_circle_add,
- VIEW3D_MT_custom_sphere_add,
- VIEW3D_MT_custom_empty_add,
- VIEW3D_MT_custom_cube_add,
- VIEW3D_MT_custom_curve_add,
- VIEW3D_MT_custom_plane_add,
- VIEW3D_MT_custom_extras_add,
- ADD_MESH_MT_pie,
- )
- def register():
- for cls in classes:
- bpy.utils.register_class(cls)
- def unregister():
- for cls in classes:
- bpy.utils.unregister_class(cls)
- if __name__ == "__main__":
- register()
- bpy.ops.wm.call_menu_pie(name="ADD_MESH_MT_pie")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement