How to toggle visibible / selectable / renderable for multiple objects? For quite long time, I was looking for a faster way to toggle (or toggle off) visible / selectable and renderable for many objects, as illustrated below:





I know we can do the relatively quick select by dragging in the Outliner, but it is not so fast though; Also, we can try H and AltH, as well as Ristrict Render, but the objects must be selectable first.

So, how can I do this in a faster way? Script would be acceptable, if necessary.



Edit:

To simplify my question in another way: Is there a way to make all hilighted items listed in Outliner to have either of these properties unified?  For example, I want to have all objects selectable, what should I do instead of having to toggling them one by one? Intuitively, I tried to press A twice in Outliner, then hit S, I thought it would work similar to what A works everywhere, I mean a kind of "unified" toggle, to toggle all of them on or off, regardless their initial slectibility. But appearently it cannot be done in this way. So I'm looking for a better way to do this.

The only way I can think is to group them all first, then switch the outliner display type to Groups, now I can toggle them all by a single click. However, four problems here:


Again, It doesn't work with the unselectable or invisible ones, which cannot be grouped since I cannot even select them.
it means I have to give up the current selection first, which is sometimes unwanted.
Even if all objects are initially selectable and I don't care to give up the current selection, creating a temporary group then delete it afterwards seems not as fast as expected.
I'm particularly talking about a complicated scene with a large number of objects, which makes Outliner the important place to organize them.
The outliner is written in C, and not much is exposed to Python.

The operator that toggles the (render-)visibility or selectability is:

bpy.ops.outliner.object_operation()


Possible arguments for the type parameter are:

('SELECT', 'DESELECT', 'SELECT_HIERARCHY', 'DELETE', 'TOGVIS', 'TOGSEL', 'TOGREN', 'RENAME')


As you see, there are only toggles. Someone had to add some to only turn on or only turn off all pre-selected items (would unify the settings). Seems like a simple C task, but not sure how to do the interaction with the user...

Wouldn't make much sense to clutter the right-click menu with


  Toggle Visible
  Make Visible
  Make Invisible
  Toggle Selectable
  Make Selectable
  Make Unselectable
  Toggle Renderable
  Make Renderable
  Make Unrenderable


Hotkeys should work well however, Shift + R/S/V to turn all on, Alt + R/S/V to turn all off. Ctrl + ... wouldn't work, 'cause CtrlS is globally for save .blend.



Update:

I duplicated the toggle code and changed it to set visibility/selectability/renderability. This means you can switch each of them on, just like you would toggle them. If you want to turn them all off, turn them all on, then toggle to invert. Benefit: 3 operators / entries in the right-click menu less.

It might make sense to refactor the code and have only one operator each (so 3 in total) + an enum to turn on, off or toggle. I would still add turn on and toggle to RMB menu only.

Diff: http://www.pasteall.org/49381/diff

Windows 64bit build: http://graphicall.org/1101