Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ##### BEGIN GPL LICENSE BLOCK #####
- #
- # This program is free software; you can redistribute it and/or
- # modify it under the terms of the GNU General Public License
- # as published by the Free Software Foundation; either version 2
- # of the License, or (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software Foundation,
- # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- #
- # ##### END GPL LICENSE BLOCK #####
- # <pep8 compliant>
- bl_info = {
- "name": "Rhubarb pie",
- "author": "Hadrien Brissaud",
- "version": (0, 1),
- "blender": (2, 77),
- "description": "Enable rhubarb pie",
- "category": "User Interface",
- }
- import bpy
- from bpy.types import Menu, Operator
- from bpy.props import EnumProperty
- class multiselect(bpy.types.Operator):
- bl_idname = "multi.select"
- bl_label = "multi.select"
- bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- layout = self.layout
- if bpy.context.object.mode != "EDIT":
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.context.tool_settings.mesh_select_mode = (True, True, True)
- if bpy.context.object.mode == "EDIT":
- bpy.context.tool_settings.mesh_select_mode = (True, True, True)
- return {'FINISHED'}
- class add_mirror(bpy.types.Operator):
- bl_idname = "add.mirror"
- bl_label = "Add mirror"
- bl_options = {'REGISTER', 'UNDO'}
- def execute(self, context):
- bpy.ops.object.modifier_add(type='MIRROR')
- bpy.context.object.modifiers["Mirror"].use_clip = True
- return {'FINISHED'}
- class VIEW3D_PIE_object_mode(Menu):
- bl_label = "Mode"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.operator_enum("OBJECT_OT_mode_set", "mode")
- class VIEW3D_PIE_view_more(Menu):
- bl_label = "More"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.operator("VIEW3D_OT_view_persportho", text="Persp/Ortho", icon='RESTRICT_VIEW_OFF')
- pie.operator("VIEW3D_OT_camera_to_view")
- pie.operator("VIEW3D_OT_view_selected")
- pie.operator("VIEW3D_OT_view_all")
- pie.operator("VIEW3D_OT_localview")
- pie.operator("SCREEN_OT_region_quadview")
- class VIEW3D_PIE_view(Menu):
- bl_label = "View"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.operator_enum("VIEW3D_OT_viewnumpad", "type")
- pie.operator("wm.call_menu_pie", text="More", icon='PLUS').name = "VIEW3D_PIE_view_more"
- class VIEW3D_PIE_shade(Menu):
- bl_label = "Shade"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.prop(context.space_data, "viewport_shade", expand=True)
- if context.active_object:
- if(context.mode == 'EDIT_MESH'):
- pie.operator("MESH_OT_faces_shade_smooth")
- pie.operator("MESH_OT_faces_shade_flat")
- else:
- pie.operator("OBJECT_OT_shade_smooth")
- pie.operator("OBJECT_OT_shade_flat")
- class VIEW3D_manipulator_set(Operator):
- bl_label = "Set Manipulator"
- bl_idname = "view3d.manipulator_set"
- type = EnumProperty(
- name="Type",
- items=(('TRANSLATE', "Translate", "Use the manipulator for movement transformations"),
- ('ROTATE', "Rotate", "Use the manipulator for rotation transformations"),
- ('SCALE', "Scale", "Use the manipulator for scale transformations"),
- ),
- )
- def execute(self, context):
- # show manipulator if user selects an option
- context.space_data.show_manipulator = True
- context.space_data.transform_manipulators = {self.type}
- return {'FINISHED'}
- class VIEW3D_PIE_orientation(Menu):
- bl_label = "Orientation"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.prop(context.space_data, "transform_orientation", expand=True)
- class VIEW3D_PIE_pivot(Menu):
- bl_label = "Pivot"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.prop(context.space_data, "pivot_point", expand=True)
- if context.active_object.mode == 'OBJECT':
- pie.prop(context.space_data, "use_pivot_point_align", text="Center points")
- class VIEW3D_PIE_snap_target(Menu):
- bl_label = "Snap target"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.prop(context.scene.tool_settings, "snap_target", expand=True)
- pie.prop(context.scene.tool_settings, "use_snap_align_rotation", icon='SNAP_NORMAL', text="Align to target")
- pie.prop(context.scene.tool_settings, "use_snap_grid_absolute", icon='SNAP_GRID', text="Absolute grid snap")
- class VIEW3D_PIE_snap_element(Menu):
- bl_label = "Snap element"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.prop(context.scene.tool_settings, "snap_element", expand=True)
- class VIEW3D_PIE_manip(Menu):
- bl_label = "Manip"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.operator("view3d.manipulator_set", icon='MAN_TRANS', text="Translate").type = 'TRANSLATE'
- pie.operator("view3d.manipulator_set", icon='MAN_ROT', text="Rotate").type = 'ROTATE'
- pie.operator("view3d.manipulator_set", icon='MAN_SCALE', text="Scale").type = 'SCALE'
- pie.prop(context.space_data, "show_manipulator")
- pie.operator("wm.call_menu_pie", text="Orientation", icon='OUTLINER_OB_EMPTY').name = "VIEW3D_PIE_orientation"
- pie.operator("wm.call_menu_pie", text="Pivot", icon='CURSOR').name = "VIEW3D_PIE_pivot"
- pie.operator("wm.call_menu_pie", text="Snap element", icon='SNAP_SURFACE').name = "VIEW3D_PIE_snap_element"
- pie.operator("wm.call_menu_pie", text="Snap target", icon='SNAP_INCREMENT').name = "VIEW3D_PIE_snap_target"
- class VIEW3D_PIE_merge_more(Menu):
- bl_label = "Merge"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.operator_enum("MESH_OT_merge", "type")
- pie.operator("mesh.remove_doubles", text="Remove doubles")
- class VIEW3D_PIE_delete(Menu):
- bl_label = "Delete"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- if tuple (bpy.context.tool_settings.mesh_select_mode) == (True, False, False):
- pie.operator("mesh.delete", text="Delete faces").type = 'FACE'
- pie.operator("mesh.dissolve_verts", text="Dissolve vertices")
- pie.operator("mesh.delete_edgeloop", text="Delete edgeloop").use_face_split = False
- pie.operator("mesh.delete", text="Delete vertices").type = 'VERT'
- elif tuple (bpy.context.tool_settings.mesh_select_mode) == (False, True, False):
- pie.operator("mesh.delete", text="Delete faces").type = 'FACE'
- pie.operator("mesh.dissolve_edges", text="Dissolve edges").use_verts = True
- pie.operator("mesh.delete_edgeloop", text="Delete edgeloop").use_face_split = False
- pie.operator("mesh.delete", text="Delete edges").type = 'EDGE'
- elif tuple (bpy.context.tool_settings.mesh_select_mode) == (False, False, True):
- pie.operator("mesh.delete", text="Delete faces").type = 'FACE'
- pie.operator("mesh.dissolve_faces", text="Dissolve faces")
- pie.operator("mesh.delete", text="Delete only faces").type = 'ONLY_FACE'
- pie.operator("mesh.delete", text="Delete only edges and faces").type = 'EDGE_FACE'
- # définir ce qu'il se passe dans les trois conditions suivantes :
- elif tuple (bpy.context.tool_settings.mesh_select_mode) == (True, True, False):
- pie.operator("mesh.delete", text="Delete faces").type = 'FACE'
- pie.operator("mesh.dissolve_verts", text="Dissolve vertices")
- pie.operator("mesh.delete_edgeloop", text="Delete edgeloop").use_face_split = False
- pie.operator("mesh.delete", text="Delete vertices").type = 'VERT'
- elif tuple (bpy.context.tool_settings.mesh_select_mode) == (True, False, True):
- pie.operator("mesh.delete", text="Delete faces").type = 'FACE'
- pie.operator("mesh.dissolve_verts", text="Dissolve vertices")
- pie.operator("mesh.delete_edgeloop", text="Delete edgeloop").use_face_split = False
- pie.operator("mesh.delete", text="Delete vertices").type = 'VERT'
- elif tuple (bpy.context.tool_settings.mesh_select_mode) == (False, True, True):
- pie.operator("mesh.delete", text="Delete faces").type = 'FACE'
- pie.operator("mesh.dissolve_verts", text="Dissolve vertices")
- pie.operator("mesh.delete_edgeloop", text="Delete edgeloop").use_face_split = False
- pie.operator("mesh.delete", text="Delete vertices").type = 'VERT'
- elif tuple (bpy.context.tool_settings.mesh_select_mode) == (True, True, True):
- pie.operator_enum("MESH_OT_delete", "type")
- class VIEW3D_PIE_separate_more(Menu):
- bl_label = "Separate"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.operator_enum("mesh.separate", "type")
- class VIEW3D_PIE_select_more(Menu):
- bl_label = "Select"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.operator("mesh.select_less", text="Contract", icon='FULLSCREEN_EXIT')
- pie.operator("mesh.select_more", text="Expand", icon='FULLSCREEN_ENTER')
- pie.operator("mesh.select_linked", text="Linked")
- pie.operator("mesh.select_all", text="Invert").action = 'INVERT'
- pie.operator("mesh.region_to_loop", text="Boundary loop")
- pie.operator("mesh.loop_to_region", text="Inner-region")
- pie.operator("mesh.select_nth", text="Checker deselect")
- pie.operator("mesh.select_random", text="Random")
- class VIEW3D_PIE_selection_mode(Menu):
- bl_label = "Selection mode"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.operator("view3d.select_circle", text="Circle select")
- pie.operator("view3d.select_border", text="Box select")
- class VIEW3D_PIE_proportional_mesh(Menu):
- bl_label = "Proportional edit"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.prop(context.scene.tool_settings, "proportional_edit", expand=True)
- class VIEW3D_PIE_mesh(Menu):
- bl_label = "Mesh"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- pie.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
- pie.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
- pie.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
- pie.operator("wm.call_menu_pie", text="Select...", icon='EDIT').name = "VIEW3D_PIE_select_more"
- pie.operator("multi.select", text="Multi", icon='LOOPSEL')
- pie.operator("screen.redo_last", text="Last operator", icon='SHORTDISPLAY')
- pie.operator("wm.call_menu_pie", text="Proportional edit", icon='PROP_CON').name = "VIEW3D_PIE_proportional_mesh"
- pie.operator("view3d.snap_cursor_to_selected", text="Cursor to selection", icon='CURSOR')
- class VIEW3D_PIE_mesh_extrude(Menu):
- bl_label = "Extrude"
- def draw(self, context):
- layout = self.layout
- pie = layout.menu_pie()
- op1 = pie.operator(mesh.extrude_region_move(MESH_OT_extrude_region={"mirror":False}, TRANSFORM_OT_translate={"constraint_axis":(False, False, True), "constraint_orientation":'NORMAL'}), text="Extrude straight")
- op1
- '''
- extrude_normal_average_op = pie.operator("mesh.extrude_region_move", "transform_translate", text="Extrude straight")
- extrude_normal_average_op.constraint_axis=(False, False, True)
- extrude_normal_average_op.constraint_orientation='NORMAL'
- extrude_free_op = pie.operator("mesh.extrude_region_move", text="Extrude free")
- extrude_free_op.constraint_axis=(False, False, False)
- extrude_free_op.constraint_orientation='GLOBAL'
- extrude_along_normals_evenly_op = pie.operator("mesh.extrude_region_shrink_fatten", text="Extrude along normals evenly")
- extrude_along_normals_evenly_op.use_even_offset=True
- extrude_along_normals_op = pie.operator("mesh.extrude_region_shrink_fatten", text="Extrude along normals")
- extrude_along_normals_op.use_even_offset=False
- pie.operator("mesh.extrude_faces_move", text="Extrude individual")
- pie.operator("mesh.extrude_vertices_move", text="Extrude vertices")
- pie.operator("mesh.extrude_edges_move", text="Extrude edges")
- '''
- class VIEW3D_PIE_mesh_tools_more(Menu):
- bl_label = "More tools"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.operator("mesh.symmetrize", text="Symmetrize")
- pie.operator("mesh.bridge_edge_loops", text="Bridge")
- pie.operator("wm.call_menu_pie", text="Separate...").name = "VIEW3D_PIE_separate_more"
- pie.operator("mesh.bisect", text="Bisect")
- pie.operator("mesh.convex_hull", text="Convex hull")
- pie.operator("mesh.intersect", text="Intersect")
- pie.operator("mesh.offset_edge_loops_slide", text="Offset edge loops")
- pie.operator("mesh.fill_grid", text="Grid fill")
- class VIEW3D_PIE_mesh_tools(Menu):
- bl_label = "Mesh tools"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.operator("mesh.loopcut_slide", text="Loopcut")
- pie.operator("mesh.knife_tool", text="Knife")
- if tuple (bpy.context.tool_settings.mesh_select_mode) == (True, False, False):
- bevel_op = pie.operator("mesh.bevel", text="Bevel")
- bevel_op.segments=2
- bevel_op.vertex_only=True
- else:
- pie.operator("mesh.bevel", text="Bevel").segments=2
- pie.operator("wm.call_menu_pie", text="Merge...", icon='AUTOMERGE_ON').name = "VIEW3D_PIE_merge_more"
- pie.operator("mesh.vert_connect", text="Connect")
- pie.operator("mesh.vertices_smooth", text="Smooth")
- pie.operator("mesh.intersect_boolean", text="Boolean")
- pie.operator("mesh.inset", text="Inset")
- class VIEW3D_PIE_object(Menu):
- bl_label = "Object"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- scene = context.scene
- pie = layout.menu_pie()
- pie.operator("group.objects_add_active", text="Add to active group", icon='ZOOMIN')
- pie.operator("group.objects_remove", text="Remove from group", icon='ZOOMOUT')
- pie.operator("object.join", text="Join", icon ='ROTATECENTER')
- pie.operator("object.select_linked", text="Select by data", icon='MESH_DATA').type='OBDATA'
- pie.operator("add.mirror", text="Add mirror", icon='MOD_MIRROR')
- pie.operator("screen.redo_last", text="Last operator", icon='SHORTDISPLAY')
- pie.prop(scene.tool_settings, "use_proportional_edit_objects", text="Proportional edit")
- pie.operator("view3d.snap_cursor_to_selected", text="Cursor to selection", icon='CURSOR')
- class VIEW3D_PIE_origin(Menu):
- bl_label = "Set origin"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.operator("object.origin_set", text="Geometry to origin").type='GEOMETRY_ORIGIN'
- pie.operator("object.origin_set", text="Origin to geometry").type='ORIGIN_GEOMETRY'
- pie.operator("object.origin_set", text="Origin to center of mass").type='ORIGIN_CENTER_OF_MASS'
- pie.operator("object.origin_set", text="Origin to cursor").type='ORIGIN_CURSOR'
- class VIEW3D_PIE_proportional_falloff(Menu):
- bl_label = "Falloff"
- def draw(self, context):
- layout = self.layout
- ob = context.object
- pie = layout.menu_pie()
- pie.prop(context.scene.tool_settings, "proportional_edit_falloff", expand=True)
- addon_keymaps = []
- classes = (
- VIEW3D_manipulator_set,
- VIEW3D_PIE_object_mode,
- VIEW3D_PIE_view,
- VIEW3D_PIE_view_more,
- VIEW3D_PIE_shade,
- VIEW3D_PIE_orientation,
- VIEW3D_PIE_pivot,
- VIEW3D_PIE_snap_target,
- VIEW3D_PIE_snap_element,
- VIEW3D_PIE_manip,
- VIEW3D_PIE_merge_more,
- VIEW3D_PIE_delete,
- VIEW3D_PIE_select_more,
- VIEW3D_PIE_selection_mode,
- VIEW3D_PIE_separate_more,
- VIEW3D_PIE_proportional_mesh,
- VIEW3D_PIE_mesh,
- VIEW3D_PIE_mesh_extrude,
- VIEW3D_PIE_mesh_tools,
- VIEW3D_PIE_mesh_tools_more,
- VIEW3D_PIE_object,
- VIEW3D_PIE_origin,
- VIEW3D_PIE_proportional_falloff,
- add_mirror,
- multiselect,
- )
- def register():
- for cls in classes:
- bpy.utils.register_class(cls)
- wm = bpy.context.window_manager
- def unregister():
- for cls in classes:
- bpy.utils.unregister_class(cls)
- wm = bpy.context.window_manager
- if wm.keyconfigs.addon:
- for km in addon_keymaps:
- for kmi in km.keymap_items:
- km.keymap_items.remove(kmi)
- wm.keyconfigs.addon.keymaps.remove(km)
- addon_keymaps.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement