xeoncat

ui_pie_uvmap.py

Dec 2nd, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.56 KB | None | 0 0
  1. bl_info = {
  2.     "name": "UV Unwrap Pie Menu",
  3.     "description": "Pie Menu for UV Unwrap and Mark Seams function. default key U in category Mesh as mesh.pie_uvmap",
  4.     "author": "Filipe xeoncat Miranda",
  5.     "version": (0, 1),
  6.     "blender": (2, 79, 0),
  7.     "location": "",
  8.     "warning": "",
  9.     "wiki_url": "",
  10.     "category": "Pie Menu"
  11.     }
  12.  
  13. import bpy
  14. from bpy.types import Menu
  15.  
  16. class MESH_PIE_uvproject(Menu):
  17.     bl_idname = "mesh.pie_uvproject"
  18.     bl_label = "Pie UV Project"
  19.     bl_options = {'REGISTER', 'UNDO'}
  20.  
  21.     def draw(self, context):
  22.         layout = self.layout
  23.         pie = layout.menu_pie()
  24.         box = pie.split().column()
  25.        
  26.         box.operator("uv.cube_project", text="Cube Project", icon='MESH_CUBE')
  27.         box.operator("uv.cylinder_project", text="Cylinder Project", icon='MESH_CYLINDER')
  28.         box.operator("uv.sphere_project", text="Sphere Project", icon='MESH_UVSPHERE')
  29.         box.operator("uv.lightmap_pack")
  30.         box.operator("uv.follow_active_quads")
  31.         box.operator("uv.project_from_view").scale_to_bounds = True
  32.  
  33.  
  34. class MESH_PIE_uvmap(Menu):
  35.  
  36.     bl_label = "UV Mapping"
  37.     bl_idname = "mesh.pie_uvmap"
  38.     bl_options = {'REGISTER', 'UNDO'}
  39.  
  40.     def draw(self, context):
  41.         layout = self.layout
  42.  
  43.         pie = layout.menu_pie()
  44.        
  45.         pie.operator("mesh.mark_seam", text="Mark Seam", icon='ZOOMIN').clear = False
  46.         pie.operator("mesh.mark_seam", text="Clear Seam", icon='ZOOMOUT').clear = True
  47.         pie.menu("mesh.pie_uvproject", text="Other Projections", icon='TRIA_DOWN')
  48.         pie.operator("uv.unwrap", text="UV Unwrap", icon='MESH_GRID')
  49.         pie.operator("uv.smart_project")
  50.         pie.operator("uv.reset")
  51.      
  52.  
  53. classes = (
  54.     MESH_PIE_uvproject,
  55.     MESH_PIE_uvmap,
  56.     )    
  57.  
  58. addon_keymaps = []
  59.  
  60.  
  61. def register():
  62.     for cls in classes:
  63.         bpy.utils.register_class(cls)
  64.    
  65.     wm = bpy.context.window_manager
  66.     kc = wm.keyconfigs.addon
  67.    
  68.     if kc:
  69.         km = wm.keyconfigs.addon.keymaps.new(name='Mesh')
  70.         kmi = km.keymap_items.new('wm.call_menu_pie', 'U', 'PRESS', shift=False,ctrl=False)
  71.         kmi.properties.name = "mesh.pie_uvmap"
  72.         addon_keymaps.append((km, kmi))
  73.  
  74.  
  75. def unregister():
  76.     wm = bpy.context.window_manager
  77.     kc = wm.keyconfigs.addon
  78.    
  79.     if kc:
  80.         for km, kmi in addon_keymaps:
  81.             km.keymap_items.remove(kmi)
  82.            
  83.     addon_keymaps.clear()
  84.    
  85.     for cls in classes:
  86.         bpy.utils.unregister_class(cls)
  87.  
  88.  
  89. if __name__ == "__main__":
  90.     register()
Advertisement
Add Comment
Please, Sign In to add comment