4
$\begingroup$

Is there a way to toggle objects' ability to be selected on/off with a hotkey similar to hiding objects with Shift + H / Alt + H?

$\endgroup$
4
$\begingroup$

Short Answer

No, there isn't.

Long Answer

I just looked it up and it seems that there is not a hotkey for that by default, so I whipped up an addon real quick to do it. Install this and you can add a shortcut to it if you'd like. Another trick is to press and drag over the toggles in the outliner (this actually works just about everywhere in Blender's UI) to quickly enable objects that are close together in the outliner. The add-on can be found in the tool context in the 3d view. Just copy this into a text editor like notepad (simpler is better) and save it as quick_toggle_selectability.py, then install it like you would any other add-on.

# Copyright 2016 Jake Dube
#
# ##### 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 3 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, see <http://www.gnu.org/licenses/>.
#
# ##### END GPL LICENSE BLOCK #####

bl_info = {
    "name": "Selectability Toggle",
    "author": "Jake Dube",
    "version": (1, 0),
    "blender": (2, 76, 0),
    "location": "3D View > Tools > Select",
    "description": "Button to toggle selectability",
    "wiki_url": "",
    "category": "3D View",
    }

import bpy
from bpy.types import Scene, Panel, Operator
from bpy.props import EnumProperty

class SelectabilityTogglePanel(Panel):
    bl_label = "Selectability Toggle"
    bl_idname = "3D_VIEW_PT_layout_SelectabilityToggle"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = 'Tools'

    def draw(self, context):
        scene = context.scene
        layout = self.layout
        layout.operator("scene.quick_toggle_selectability", icon="RESTRICT_SELECT_OFF")
        layout.prop(scene, "action", text="")

class SelectabilityToggleOperator(Operator):
    bl_label = "Selectability Toggle"
    bl_idname = "scene.quick_toggle_selectability"
    bl_description = "Toggle/Disable selectability"
    bl_options = {'REGISTER', 'UNDO'}

    def execute(self,context):
        scene = context.scene

        for active in bpy.context.selected_objects:
            bpy.context.scene.objects.active = active

            if scene.action == 'TOGGLE':
                active.hide_select = not active.hide_select
            elif scene.action == 'ENABLE':
                active.hide_select = False
            else:
                active.hide_select = True

        return {'FINISHED'}

classes = [SelectabilityTogglePanel, SelectabilityToggleOperator]

def register():
    for i in classes:
        bpy.utils.register_class(i)

    Scene.action = EnumProperty(
        items=[('TOGGLE', "Toggle", ""),
               ('ENABLE', "Enable", ""),
               ('DISABLE', "Disable", "")],
        name="Action",
        description="What the button does to selected object's selectability",
        default="TOGGLE")

def unregister():
    for i in classes:
        bpy.utils.unregister_class(i)

    del Scene.action

if __name__ == "__main__":
    register()
$\endgroup$
  • $\begingroup$ I have installed it but cannot understand how to make it work, what menu does what? Should I click on the button or just switch the menu state? $\endgroup$ – MicroMachine Aug 31 '17 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.