Skip to content
Snippets Groups Projects
space_view3d_spacebar_menu.py 45.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • 
            layout.separator()
    
            layout.operator("pose.select_all", text="Select/Deselect All")
            layout.operator("pose.select_inverse", text="Inverse")
            layout.operator("pose.select_constraint_target", text="Constraint Target")
            layout.operator("pose.select_linked", text="Linked")
    
            layout.separator()
    
            layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
            layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
    
            layout.separator()
    
            props = layout.operator("pose.select_hierarchy", text="Extend Parent")
            props.extend = True
            props.direction = 'PARENT'
    
            props = layout.operator("pose.select_hierarchy", text="Extend Child")
            props.extend = True
            props.direction = 'CHILD'
    
            layout.separator()
    
            layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
            layout.operator("object.select_pattern", text="Select Pattern...")
    
    class VIEW3D_MT_PoseCopy(bpy.types.Menu):
        bl_label = "Pose Copy"
    
        def draw(self, context):
            layout = self.layout
    		 
            layout.operator("pose.copy")
            layout.operator("pose.paste")
            layout.operator("pose.paste",
               text="Paste X-Flipped Pose").flipped = True
            layout.separator()
    
    class VIEW3D_MT_PoseNames(bpy.types.Menu):
        bl_label = "Pose Copy"
    
        def draw(self, context):
            layout = self.layout
    		 
            layout.operator_context = 'EXEC_AREA'
            layout.operator("pose.autoside_names",
                text="AutoName Left/Right").axis = 'XAXIS'
            layout.operator("pose.autoside_names",
                text="AutoName Front/Back").axis = 'YAXIS'
            layout.operator("pose.autoside_names",
                text="AutoName Top/Bottom").axis = 'ZAXIS'
    
            layout.operator("pose.flip_names")
    
    
    class VIEW3D_MT_SelectSurface(bpy.types.Menu):
        bl_label = "Select Menu"
    
        def draw(self, context):
            layout = self.layout
    
            layout.operator("view3d.select_border")
            layout.operator("view3d.select_circle")
    
            layout.separator()
    
            layout.operator("curve.select_all", text="Select/Deselect All")
            layout.operator("curve.select_inverse")
            layout.operator("curve.select_random")
            layout.operator("curve.select_every_nth")
    
            layout.separator()
    
            layout.operator("curve.select_row")
    
            layout.separator()
    
            layout.operator("curve.select_more")
            layout.operator("curve.select_less")
    
    class VIEW3D_MT_SelectMetaball(bpy.types.Menu):
        bl_label = "Select Menu"
    
        def draw(self, context):
            layout = self.layout
    
            layout.operator("view3d.select_border")
    
            layout.separator()
    
            #layout.operator("mball.select_deselect_all_metaelems")
            layout.operator("mball.select_inverse_metaelems")
    
            layout.separator()
    
            layout.operator("mball.select_random_metaelems")
    
    class VIEW3D_MT_edit_TK(bpy.types.Menu):
        bl_label = "Edit Mesh"
    
        def draw(self, context):
            layout = self.layout
            row = layout.row()
    
            layout.operator_context = 'INVOKE_REGION_WIN'
    
            prop = layout.operator("wm.context_set_value",
                text="Select By Vertex", icon='VERTEXSEL')
            prop.value = "(True, False, False)"
            prop.path = "tool_settings.mesh_selection_mode"
            layout.menu("VIEW3D_MT_edit_mesh_vertices", icon='VERTEXSEL')
    
            prop = layout.operator("wm.context_set_value",
                text="Select By Edge", icon='EDGESEL')
            prop.value = "(False, True, False)"
            prop.path = "tool_settings.mesh_selection_mode"
            layout.menu("VIEW3D_MT_edit_mesh_edges", icon='EDGESEL')
    
            prop = layout.operator("wm.context_set_value",
                text="Select By Face", icon='FACESEL')
            prop.value = "(False, False, True)"
            prop.path = "tool_settings.mesh_selection_mode"
            layout.menu("VIEW3D_MT_edit_mesh_faces", icon='FACESEL')
            layout.separator()
    
            layout.menu("VIEW3D_MT_edit_mesh_normals", icon='META_DATA')
            layout.operator("mesh.loopcut_slide",
                text="Loopcut", icon='EDIT_VEC')
    
    class VIEW3D_MT_editM_Edge(bpy.types.Menu):
        bl_label = "Edges"
    
        def draw(self, context):
            layout = self.layout
            layout.operator_context = 'INVOKE_REGION_WIN'
    
            layout.operator("mesh.mark_seam")
            layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
            layout.separator()
    
            layout.operator("mesh.mark_sharp")
            layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
            layout.operator("mesh.extrude_move_along_normals", text="Extrude")
            layout.separator()
    
            layout.operator("mesh.edge_rotate",
                text="Rotate Edge CW").direction = 'CW'
            layout.operator("mesh.edge_rotate",
                text="Rotate Edge CCW").direction = 'CCW'
            layout.separator()
    
            layout.operator("TFM_OT_edge_slide", text="Edge Slide")
            layout.operator("mesh.loop_multi_select", text="Edge Loop")
            layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
            layout.operator("mesh.loop_to_region")
            layout.operator("mesh.region_to_loop")
    
    
    class VIEW3D_MT_EditCurveCtrlpoints(bpy.types.Menu):
        bl_label = "Control Points"
    
        def draw(self, context):
            layout = self.layout
    
            edit_object = context.edit_object
    
            if edit_object.type == 'CURVE':
                layout.operator("transform.transform").mode = 'TILT'
                layout.operator("curve.tilt_clear")
                layout.operator("curve.separate")
    
                layout.separator()
    
                layout.operator_menu_enum("curve.handle_type_set", "type")
    
                layout.separator()
    
                layout.menu("VIEW3D_MT_hook")
    
    
    class VIEW3D_MT_EditCurveSegments(bpy.types.Menu):
        bl_label = "Curve Segments"
    
        def draw(self, context):
            layout = self.layout
    
            layout.operator("curve.subdivide")
            layout.operator("curve.switch_direction")
    
    class VIEW3D_MT_EditCurveSpecials(bpy.types.Menu):
        bl_label = "Specials"
    
        def draw(self, context):
            layout = self.layout
    
            layout.operator("curve.subdivide")
            layout.operator("curve.switch_direction")
            layout.operator("curve.spline_weight_set")
            layout.operator("curve.radius_set")
            layout.operator("curve.smooth")
            layout.operator("curve.smooth_radius")
    
    class VIEW3D_MT_EditArmatureTK(bpy.types.Menu):
        bl_label = "Armature Tools"
    
        def draw(self, context):
            layout = self.layout
    
            # Edit Armature
    
            layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
    
            layout.operator("transform.transform", text="Scale B-Bone Width").mode = 'BONESIZE'
    
            layout.separator()
    
            layout.operator("armature.extrude_move")
    
            layout.operator("armature.extrude_forked")
    
            layout.operator("armature.duplicate_move")
            layout.operator("armature.merge")
            layout.operator("armature.fill")
            layout.operator("armature.delete")
            layout.operator("armature.separate")
    
            layout.separator()
    
            layout.operator("armature.subdivide_multi", text="Subdivide")
            layout.operator("armature.switch_direction", text="Switch Direction")
    
    class VIEW3D_MT_ArmatureName(bpy.types.Menu):
        bl_label = "Armature Name"
    
        def draw(self, context):
            layout = self.layout
    
            layout.operator_context = 'EXEC_AREA'
            layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
            layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
            layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
            layout.operator("armature.flip_names")
            layout.separator()
    
    class VIEW3D_MT_KeyframeMenu(bpy.types.Menu):
        bl_label = "Keyframe Menu"
    
        def draw(self, context):
            layout = self.layout
    
            # Keyframe Bleck
            layout.operator("anim.keyframe_insert_menu",
                text="Insert Keyframe...")
            layout.operator("anim.keyframe_delete_v3d",
                text="Delete Keyframe...")
            layout.operator("anim.keying_set_active_set",
                text="Change Keying Set...")
            layout.separator()
    
    class VIEW3D_MT_CursorMenu(bpy.types.Menu):
        bl_label = "Snap Cursor Menu"
    
        def draw(self, context):
    
            layout = self.layout
            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("view3d.snap_cursor_to_selected",
    
                text="Cursor to Selected")
            layout.operator("view3d.snap_cursor_to_center",
                text="Cursor to Center")
    
            layout.operator("view3d.snap_cursor_to_grid",
    
            layout.operator("view3d.snap_cursor_to_active",
                text="Cursor to Active")
    
            layout.separator()
            layout.operator("view3d.snap_selected_to_cursor",
                text="Selection to Cursor")
    
            layout.operator("view3d.snap_selected_to_grid",
                text="Selection to Grid")
            layout.separator()
            layout.operator("view3d.pivot_cursor",
                text="Set Cursor as Pivot Point")
            layout.operator("view3d.revert_pivot",
                text="Revert Pivot Point")
    
    class VIEW3D_MT_undoS(bpy.types.Menu):
        bl_label = "Undo/Redo"
    
        def draw(self, context):
            layout = self.layout
            layout.operator_context = 'INVOKE_REGION_WIN'
            layout.operator("ed.undo", icon='TRIA_LEFT')
            layout.operator("ed.redo", icon='TRIA_RIGHT')
    
    def register():
        bpy.types.register(VIEW3D_MT_Space_Dynamic_Menu)
        bpy.types.register(VIEW3D_MT_AddMenu)
        bpy.types.register(VIEW3D_MT_TransformMenu)
        bpy.types.register(VIEW3D_MT_MirrorMenu)
        bpy.types.register(VIEW3D_MT_ParentMenu)
        bpy.types.register(VIEW3D_MT_GroupMenu)
        bpy.types.register(VIEW3D_MT_AlignMenu)
        bpy.types.register(VIEW3D_MT_SelectMenu)
        bpy.types.register(VIEW3D_MT_SelectEditMenu)
        bpy.types.register(VIEW3D_MT_SelectCurveMenu)
        bpy.types.register(VIEW3D_MT_SelectPoseMenu)
        bpy.types.register(VIEW3D_MT_PoseCopy)
        bpy.types.register(VIEW3D_MT_PoseNames)
        bpy.types.register(VIEW3D_MT_KeyframeMenu)
        bpy.types.register(VIEW3D_MT_SelectArmatureMenu)
        bpy.types.register(VIEW3D_MT_ArmatureName)
        bpy.types.register(VIEW3D_MT_SelectMetaball)
        bpy.types.register(VIEW3D_MT_SelectSurface)
        bpy.types.register(VIEW3D_MT_edit_TK)
        bpy.types.register(VIEW3D_MT_EditArmatureTK)
        bpy.types.register(VIEW3D_MT_editM_Edge)
        bpy.types.register(VIEW3D_MT_EditCurveCtrlpoints)
        bpy.types.register(VIEW3D_MT_EditCurveSegments)
        bpy.types.register(VIEW3D_MT_EditCurveSpecials)
        bpy.types.register(pivot_cursor)
        bpy.types.register(revert_pivot)
        bpy.types.register(VIEW3D_MT_CursorMenu)
        bpy.types.register(VIEW3D_MT_undoS)
    
        km = bpy.context.manager.active_keyconfig.keymaps['3D View']
        kmi = km.items.add('wm.call_menu', 'SPACE', 'PRESS')
        kmi.properties.name = "VIEW3D_MT_Space_Dynamic_Menu"
    
    
    def unregister():
        bpy.types.unregister(VIEW3D_MT_Space_Dynamic_Menu)
        bpy.types.unregister(VIEW3D_MT_AddMenu)
        bpy.types.unregister(VIEW3D_MT_TransformMenu)
        bpy.types.unregister(VIEW3D_MT_MirrorMenu)
        bpy.types.unregister(VIEW3D_MT_ParentMenu)
        bpy.types.unregister(VIEW3D_MT_GroupMenu)
        bpy.types.unregister(VIEW3D_MT_AlignMenu)
        bpy.types.unregister(VIEW3D_MT_SelectMenu)
        bpy.types.unregister(VIEW3D_MT_SelectEditMenu)
        bpy.types.unregister(VIEW3D_MT_SelectCurveMenu)
        bpy.types.unregister(VIEW3D_MT_SelectPoseMenu)
        bpy.types.unregister(VIEW3D_MT_PoseCopy)
        bpy.types.unregister(VIEW3D_MT_PoseNames)
        bpy.types.unregister(VIEW3D_MT_KeyframeMenu)
        bpy.types.unregister(VIEW3D_MT_SelectArmatureMenu)
        bpy.types.unregister(VIEW3D_MT_ArmatureName)
        bpy.types.unregister(VIEW3D_MT_SelectMetaball)
        bpy.types.unregister(VIEW3D_MT_SelectSurface)
        bpy.types.unregister(VIEW3D_MT_edit_TK)
        bpy.types.unregister(VIEW3D_MT_EditArmatureTK)
        bpy.types.unregister(VIEW3D_MT_editM_Edge)
        bpy.types.unregister(VIEW3D_MT_EditCurveCtrlpoints)
        bpy.types.unregister(VIEW3D_MT_EditCurveSegments)
        bpy.types.unregister(VIEW3D_MT_EditCurveSpecials)
        bpy.types.unregister(pivot_cursor)
        bpy.types.unregister(revert_pivot)
        bpy.types.unregister(VIEW3D_MT_CursorMenu)
        bpy.types.unregister(VIEW3D_MT_undoS)
    
        km = bpy.context.manager.active_keyconfig.keymaps['3D View']
        for kmi in km.items:
            if kmi.idname == 'wm.call_menu':
    
    Brendon Murphy's avatar
    Brendon Murphy committed
                if kmi.properties.name == "VIEW3D_MT_Space_Dynamic_Menu":
    
                    km.remove_item(kmi)
                    break
    
    if __name__ == "__main__":
        register()