Advertisement
Guest User

Untitled

a guest
Nov 13th, 2019
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 11.20 KB | None | 0 0
  1. import bpy
  2. from bpy.types import Menu
  3. from bpy.types import Operator
  4.  
  5.  
  6. bl_info = {
  7.     "name": "Custom Add Mesh Pie Menu",
  8.     "author": "Jake Mobley",
  9.     "version": (1, 0),
  10.     "blender": (2, 80, 0),    
  11.     "description": "Pie Menu to add a new Object",
  12.     "warning": "Make sure Extra Objects and Extra Curve Objects are enabled ",
  13.     "wiki_url": "",
  14.     "category": "Add Mesh",
  15. }
  16.  
  17.  
  18. class ADD_MESH_MT_pie(Menu):
  19.    
  20.    
  21.    
  22.     bl_label = "Add Mesh"
  23.     bl_idname = "ADD_MESH_MT_pie"
  24.    
  25.     def draw(self, context):
  26.         layout = self.layout
  27.         pie = layout.menu_pie()
  28. #        LEFT
  29.         pie.menu("VIEW3D_MT_custom_cube_add", icon="MESH_CUBE", text= "Cube")      
  30. #        RIGHT
  31.         pie.menu("VIEW3D_MT_cylinder_add")
  32. #        Bottom
  33.         pie.menu("VIEW3D_MT_custom_curve_add", icon="CURVE_DATA", text= "Curves")
  34. #        TOP
  35.         pie.menu("VIEW3D_MT_sphere_add")          
  36. #        10:00
  37.         pie.menu("VIEW3D_MT_circle_add", icon="MESH_CIRCLE", text = "Circle")
  38. #        2:00
  39.         pie.menu("VIEW3D_MT_custom_plane_add", icon="MESH_PLANE", text= "Plane")
  40. #        7:00
  41.         pie.menu("VIEW3D_MT_empty_add", icon="EMPTY_AXIS", text= "Empty")
  42. #        5:00
  43.         pie.menu("VIEW3D_MT_custom_extras_add", icon="BRUSH_TEXFILL", text= "Extra Objects")
  44.  
  45.        
  46. class VIEW3D_MT_custom_cylinder_add(Menu):
  47.     bl_idname = "VIEW3D_MT_cylinder_add"
  48.     bl_label = "Cylinder"
  49.    
  50.     def draw(self, context):
  51.         layout = self.layout
  52.         pie = layout.menu_pie()      
  53.         split = pie.split()
  54.         col = split.column()
  55.        
  56.                
  57.         col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-6").type = 'Cyl_6'        
  58.         col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-8").type = 'Cyl_8'
  59.         col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-16").type = 'Cyl_16'        
  60.         col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-24").type = 'Cyl_24'
  61.         col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-32").type = 'Cyl_32'
  62.         col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-48").type = 'Cyl_48'
  63.         col.operator("view3d.add_cust_primitive", icon='MESH_CYLINDER', text = "Cylinder-64").type = 'Cyl_64'
  64.        
  65.        
  66.    
  67. class VIEW3D_MT_custom_circle_add(Menu):
  68.     bl_idname = "VIEW3D_MT_circle_add"
  69.     bl_label = "Circle"
  70.    
  71.     def draw(self, context):
  72.         layout = self.layout
  73.         pie = layout.menu_pie()      
  74.         split = pie.split()
  75.         col = split.column()
  76.        
  77.                
  78.         col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-6").type = 'Circle_6'        
  79.         col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-8").type = 'Circle_8'
  80.         col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-16").type = 'Circle_16'        
  81.         col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-24").type = 'Circle_24'
  82.         col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-32").type = 'Circle_32'
  83.         col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-48").type = 'Circle_48'
  84.         col.operator("view3d.add_cust_primitive", icon='MESH_CIRCLE', text = "Circle-64").type = 'Circle_64'
  85.        
  86.        
  87.    
  88. class VIEW3D_MT_custom_sphere_add(Menu):
  89.     bl_idname = "VIEW3D_MT_sphere_add"
  90.     bl_label = "Sphere"
  91.    
  92.     def draw(self, context):
  93.         layout = self.layout
  94.         pie = layout.menu_pie()      
  95.         split = pie.split()
  96.         col = split.column()
  97.        
  98.                
  99.         col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Sphere-16").type = 'UV_16'        
  100.         col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Sphere-24").type = 'UV_24'
  101.         col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Sphere-32").type = 'UV_32'        
  102.         col.operator("mesh.primitive_ico_sphere_add", icon="MESH_ICOSPHERE", text = "Icosphere")
  103.        
  104.        
  105.        
  106. class VIEW3D_MT_custom_empty_add(Menu):
  107.     bl_idname = "VIEW3D_MT_empty_add"
  108.     bl_label = "Empty"
  109.    
  110.     def draw(self, context):
  111.         layout = self.layout
  112.         pie = layout.menu_pie()      
  113.         split = pie.split()
  114.         col = split.column()
  115.        
  116.                
  117.         col.operator("view3d.add_cust_primitive", icon='EMPTY_AXIS', text = "Plain Axes").type = 'EMPTY_PL'        
  118.         col.operator("view3d.add_cust_primitive", icon='MESH_UVSPHERE', text = "Empty Sphere").type = 'EMPTY_SP'
  119.         col.operator("view3d.add_cust_primitive", icon='MESH_CUBE', text = "Empty Cube").type = 'EMPTY_CU'
  120.         col.operator("view3d.add_cust_primitive", icon='EMPTY_ARROWS', text = "Arrows").type = 'EMPTY_ARR'        
  121.         col.operator("import_image.to_plane", icon="IMAGE_DATA", text = "Image as Plane")
  122.        
  123.        
  124.        
  125. class VIEW3D_MT_custom_cube_add(Menu):
  126.     bl_idname = "VIEW3D_MT_custom_cube_add"
  127.     bl_label = "Cube"
  128.    
  129.     def draw(self, context):
  130.         layout = self.layout
  131.         pie = layout.menu_pie()      
  132.         split = pie.split()
  133.         col = split.column()
  134.        
  135.                
  136.         col.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text = "Cube")      
  137.         col.operator("mesh.primitive_round_cube_add", icon='META_CUBE', text = "Round Cube")
  138.        
  139.        
  140.        
  141. class VIEW3D_MT_custom_curve_add(Menu):
  142.     bl_idname = "VIEW3D_MT_custom_curve_add"
  143.     bl_label = "Curves"
  144.    
  145.     def draw(self, context):
  146.         layout = self.layout
  147.         pie = layout.menu_pie()      
  148.         split = pie.split()
  149.         col = split.column()
  150.        
  151.                
  152.         col.operator("curve.primitive_bezier_curve_add", icon='CURVE_DATA', text = "Bezier")      
  153.         col.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text = "Path")
  154.         col.operator("curve.primitive_bezier_circle_add", icon='CURVE_NCIRCLE', text = "Circle")
  155.         col.operator("curve.spirals", icon='FORCE_VORTEX', text = "Spiral")
  156.        
  157.        
  158. class VIEW3D_MT_custom_plane_add(Menu):
  159.     bl_idname = "VIEW3D_MT_custom_plane_add"
  160.     bl_label = "Plane"
  161.    
  162.     def draw(self, context):
  163.         layout = self.layout
  164.         pie = layout.menu_pie()      
  165.         split = pie.split()
  166.         col = split.column()
  167.        
  168.                
  169.         col.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text = "Plane")
  170.         col.operator("mesh.primitive_vert_add", icon='DOT', text = "Single Vertex")    
  171.        
  172.        
  173.        
  174. class VIEW3D_MT_custom_extras_add(Menu):
  175.     bl_idname = "VIEW3D_MT_custom_extras_add"
  176.     bl_label = "Plane"
  177.    
  178.     def draw(self, context):
  179.         layout = self.layout
  180.         pie = layout.menu_pie()      
  181.         split = pie.split()
  182.         col = split.column()
  183.        
  184.         col.operator("view3d.add_cust_primitive", icon='OUTLINER_OB_ARMATURE', text = "UE4 Mannequin").type = "MANNY"        
  185.         col.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text = "Torus")
  186.         col.operator("mesh.primitive_cone_add", icon='MESH_CONE', text = "Cone")
  187.         col.operator("view3d.add_cust_primitive", icon='LATTICE_DATA', text = "Lattice").type = "LATTICE"    
  188.        
  189.      
  190.        
  191.        
  192.        
  193.  
  194. class VIEW3D_addprimitive(bpy.types.Operator):
  195.    
  196.     bl_idname = "view3d.add_cust_primitive"
  197.     bl_label = "Add Primitive"
  198.     bl_description = "Add Primitive"
  199.     bl_options = {'REGISTER', 'UNDO'}
  200.    
  201.     type = bpy.props.StringProperty(name="Type")
  202.     def invoke(self, context, event):
  203.         def prim(self, type):
  204.             if self.type == 'Cyl_6':
  205.                 bpy.ops.mesh.primitive_cylinder_add(vertices = 6)
  206.             if self.type == 'Cyl_8':
  207.                 bpy.ops.mesh.primitive_cylinder_add(vertices=8)
  208.             if self.type == 'Cyl_12':
  209.                 bpy.ops.mesh.primitive_cylinder_add(vertices=12)
  210.             if self.type == 'Cyl_16':
  211.                 bpy.ops.mesh.primitive_cylinder_add(vertices=16)
  212.             if self.type == 'Cyl_24':
  213.                 bpy.ops.mesh.primitive_cylinder_add(vertices=24)
  214.             if self.type == 'Cyl_32':
  215.                 bpy.ops.mesh.primitive_cylinder_add(vertices=32)
  216.             if self.type == 'Cyl_48':
  217.                 bpy.ops.mesh.primitive_cylinder_add(vertices=48)
  218.             if self.type == 'Cyl_64':
  219.                 bpy.ops.mesh.primitive_cylinder_add(vertices=64)
  220.             if self.type == 'Circle_6':
  221.                 bpy.ops.mesh.primitive_circle_add(vertices = 6)
  222.             if self.type == 'Circle_8':
  223.                 bpy.ops.mesh.primitive_circle_add(vertices=8)
  224.             if self.type == 'Circle_12':
  225.                 bpy.ops.mesh.primitive_circle_add(vertices=12)
  226.             if self.type == 'Circle_16':
  227.                 bpy.ops.mesh.primitive_circle_add(vertices=16)
  228.             if self.type == 'Circle_24':
  229.                 bpy.ops.mesh.primitive_circle_add(vertices=24)
  230.             if self.type == 'Circle_32':
  231.                 bpy.ops.mesh.primitive_circle_add(vertices=32)
  232.             if self.type == 'Circle_48':
  233.                 bpy.ops.mesh.primitive_circle_add(vertices=48)
  234.             if self.type == 'Circle_64':
  235.                 bpy.ops.mesh.primitive_circle_add(vertices=64)
  236.             if self.type == 'UV_16':
  237.                 bpy.ops.mesh.primitive_uv_sphere_add(segments=16, ring_count=8)
  238.             if self.type == 'UV_24':
  239.                 bpy.ops.mesh.primitive_uv_sphere_add(segments=24, ring_count=12)
  240.             if self.type == 'UV_32':
  241.                 bpy.ops.mesh.primitive_uv_sphere_add(segments=32, ring_count=16)
  242.             if self.type == 'EMPTY_PL':
  243.                 bpy.ops.object.empty_add(type='PLAIN_AXES')
  244.             if self.type == 'EMPTY_SP':
  245.                 bpy.ops.object.empty_add(type='SPHERE')
  246.             if self.type == 'EMPTY_CU':
  247.                 bpy.ops.object.empty_add(type='CUBE')
  248.             if self.type == 'EMPTY_ARR':
  249.                 bpy.ops.object.empty_add(type='ARROWS')
  250.             if self.type == 'LATTICE':
  251.                 bpy.ops.object.add(type='LATTICE')
  252.             if self.type == 'MANNY':
  253.                 bpy.ops.object.collection_instance_add(collection='mannequin_ref')
  254.            
  255.            
  256.            
  257.         prim(self, type)
  258.        
  259.                
  260.         return {'FINISHED'}
  261.        
  262.        
  263. classes = (  
  264.     VIEW3D_addprimitive,    
  265.     VIEW3D_MT_custom_cylinder_add,
  266.     VIEW3D_MT_custom_circle_add,
  267.     VIEW3D_MT_custom_sphere_add,
  268.     VIEW3D_MT_custom_empty_add,
  269.     VIEW3D_MT_custom_cube_add,
  270.     VIEW3D_MT_custom_curve_add,
  271.     VIEW3D_MT_custom_plane_add,
  272.     VIEW3D_MT_custom_extras_add,
  273.     ADD_MESH_MT_pie,
  274.    
  275.    
  276.     )
  277. def register():    
  278.     for cls in classes:        
  279.         bpy.utils.register_class(cls)
  280.        
  281.        
  282. def unregister():    
  283.     for cls in classes:
  284.         bpy.utils.unregister_class(cls)
  285.        
  286.    
  287. if __name__ == "__main__":
  288.     register()
  289.  
  290.  
  291. bpy.ops.wm.call_menu_pie(name="ADD_MESH_MT_pie")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement