Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.21 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # ##### BEGIN GPL LICENSE BLOCK #####
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. #
  19. # ##### END GPL LICENSE BLOCK #####
  20.  
  21. bl_info = {
  22. "name": "Pie Workspaces",
  23. "description": "Pie Workspaces",
  24. "author": "Laurent Laget, Lapineige",
  25. "version": (0, 1, 6),
  26. "blender": (2, 80, 1),
  27. "location": "keyboard",
  28. "warning": "Press Ctrl Alt W to use the pie.Please add the 2D animation,Masking,Video Editing and Motion Tracking workspaces manually.",
  29. "wiki_url": "",
  30. "category": "3d View"
  31. }
  32.  
  33. import bpy
  34. from bpy.types import Menu
  35.  
  36.  
  37. # Pie Workspaces - alt right mouse button
  38. class VIEW3D_PIE_workspaces(Menu):
  39. bl_idname = "pie.workspaces"
  40. bl_label = "Workspaces"
  41.  
  42. def draw(self, context):
  43. layout = self.layout
  44.  
  45. #layout.operator_context = 'INVOKE_REGION_WIN'
  46. pie = layout.menu_pie()
  47. col = pie.split().column()
  48. row = col.split(align=True)
  49.  
  50. col.operator("class.layout", text ="Layout", icon ='SCENE_DATA')
  51. col = pie.column(align=True)
  52.  
  53. col.operator("class.modeling", text ="Modeling", icon ='EDITMODE_HLT')
  54. col = pie.column(align=True)
  55.  
  56. col.operator("class.worksculpt", text ="Sculpt", icon ='SCULPTMODE_HLT')
  57. col = pie.column(align=True)
  58.  
  59. col.operator("class.uvediting", text ="UV Editing", icon ='UV_ISLANDSEL')
  60. col = pie.column(align=True)
  61.  
  62. col.operator("class.texturepaint", text ="Texture Paint", icon ='BRUSH_DATA')
  63. col = pie.column(align=True)
  64.  
  65. col.operator("class.shading", text ="Shading", icon ='MATERIAL_DATA')
  66. col = pie.column(align=True)
  67.  
  68. col.operator("class.animation", text ="3D Animation", icon ='SEQUENCE')
  69. col.operator("class.da", text ="2D Animation", icon ='GREASEPENCIL')
  70. col.operator("class.scripting", text ="Scripting", icon ='SCRIPTPLUGINS')
  71. col.operator("class.video", text ="Video Editing", icon ='RENDER_ANIMATION')
  72.  
  73. col = pie.column(align=True)
  74.  
  75. col.operator("class.rendering", text ="Rendering", icon ='SCENE')
  76. col.operator("class.compositing", text ="Compositing", icon ='RENDER_RESULT')
  77. col.operator("class.masking", text ="Masking", icon ='RESTRICT_VIEW_ON')
  78. col.operator("class.motion", text ="Motion Tracking", icon ='ANIM_DATA')
  79.  
  80. col = pie.column(align=True)
  81.  
  82.  
  83. class layout(bpy.types.Operator):
  84. bl_idname = "class.layout"
  85. bl_label = "layout"
  86.  
  87. def execute(self, context):
  88.  
  89. layout = self.layout
  90. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Layout']
  91. return {'FINISHED'}
  92.  
  93. class modeling(bpy.types.Operator):
  94. bl_idname = "class.modeling"
  95. bl_label = "modeling"
  96.  
  97. def execute(self, context):
  98.  
  99. layout = self.layout
  100. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Modeling']
  101. return {'FINISHED'}
  102.  
  103. class worksculpt(bpy.types.Operator):
  104. bl_idname = "class.worksculpt"
  105. bl_label = "worksculpt"
  106.  
  107. def execute(self, context):
  108.  
  109. layout = self.layout
  110. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Sculpting']
  111. return {'FINISHED'}
  112.  
  113. class uvediting(bpy.types.Operator):
  114. bl_idname = "class.uvediting"
  115. bl_label = "uvediting"
  116.  
  117. def execute(self, context):
  118.  
  119. layout = self.layout
  120. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['UV Editing']
  121. return {'FINISHED'}
  122.  
  123. class texturepaint(bpy.types.Operator):
  124. bl_idname = "class.texturepaint"
  125. bl_label = "texturepaint"
  126.  
  127. def execute(self, context):
  128.  
  129. layout = self.layout
  130. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Texture Paint']
  131. return {'FINISHED'}
  132.  
  133. class shading(bpy.types.Operator):
  134. bl_idname = "class.shading"
  135. bl_label = "shading"
  136.  
  137. def execute(self, context):
  138.  
  139. layout = self.layout
  140. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Shading']
  141. return {'FINISHED'}
  142.  
  143. class animation(bpy.types.Operator):
  144. bl_idname = "class.animation"
  145. bl_label = "animation"
  146.  
  147. def execute(self, context):
  148.  
  149. layout = self.layout
  150. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Animation']
  151. return {'FINISHED'}
  152.  
  153. class rendering(bpy.types.Operator):
  154. bl_idname = "class.rendering"
  155. bl_label = "rendering"
  156.  
  157. def execute(self, context):
  158.  
  159. layout = self.layout
  160. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Rendering']
  161. return {'FINISHED'}
  162.  
  163. class compositing(bpy.types.Operator):
  164. bl_idname = "class.compositing"
  165. bl_label = "compositing"
  166.  
  167. def execute(self, context):
  168.  
  169. layout = self.layout
  170. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Compositing']
  171. return {'FINISHED'}
  172.  
  173.  
  174. class da(bpy.types.Operator):
  175. bl_idname = "class.da"
  176. bl_label = "da"
  177.  
  178. def execute(self, context):
  179.  
  180. layout = self.layout
  181. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['2D Animation']
  182. return {'FINISHED'}
  183.  
  184.  
  185. class scripting(bpy.types.Operator):
  186. bl_idname = "class.scripting"
  187. bl_label = "scripting"
  188.  
  189. def execute(self, context):
  190.  
  191. layout = self.layout
  192. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Scripting']
  193. return {'FINISHED'}
  194.  
  195. class masking(bpy.types.Operator):
  196. bl_idname = "class.masking"
  197. bl_label = "masking"
  198.  
  199. def execute(self, context):
  200.  
  201. layout = self.layout
  202. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Masking']
  203. return {'FINISHED'}
  204.  
  205. class motion(bpy.types.Operator):
  206. bl_idname = "class.motion"
  207. bl_label = "Motion Tracking"
  208.  
  209. def execute(self, context):
  210.  
  211. layout = self.layout
  212. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Motion Tracking']
  213. return {'FINISHED'}
  214.  
  215. class video(bpy.types.Operator):
  216. bl_idname = "class.video"
  217. bl_label = "Video Editing"
  218.  
  219. def execute(self, context):
  220.  
  221. layout = self.layout
  222. bpy.data.window_managers['WinMan'].windows[0].workspace = bpy.data.workspaces['Video Editing']
  223. return {'FINISHED'}
  224.  
  225. classes = (
  226. VIEW3D_PIE_workspaces,
  227. modeling,
  228. worksculpt,
  229. uvediting,
  230. layout,
  231. texturepaint,
  232. shading,
  233. animation,
  234. rendering,
  235. compositing,
  236. da,
  237. scripting,
  238. masking,
  239. motion,
  240. video,
  241. )
  242.  
  243. addon_keymaps = []
  244.  
  245.  
  246. def register():
  247.  
  248. for cls in classes:
  249. bpy.utils.register_class(cls)
  250. wm = bpy.context.window_manager
  251. kc = bpy.context.window_manager.keyconfigs.addon
  252. if wm.keyconfigs.addon:
  253.  
  254. km = wm.keyconfigs.addon.keymaps.new(name = "Window",space_type='EMPTY', region_type='WINDOW')
  255.  
  256. kmi = km.keymap_items.new('wm.call_menu_pie', 'W', 'PRESS' ,alt=True,ctrl=True)
  257. kmi.properties.name = "pie.workspaces"
  258. addon_keymaps.append((km,kmi))
  259.  
  260. def unregister():
  261. for cls in classes:
  262. bpy.utils.unregister_class(cls)
  263.  
  264. wm = bpy.context.window_manager
  265. kc = wm.keyconfigs.addon
  266. if kc:
  267. for km, kmi in addon_keymaps:
  268. km.keymap_items.remove(kmi)
  269. addon_keymaps.clear()
  270.  
  271.  
  272. if __name__ == "__main__":
  273. register()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement