Collection Visibility

Made this little addon for quick switching between objects type visibility in the collection.


Updated:
Collection_Visibility.py (5.1 KB)

It’s a very simple,
allows to change for multiple selected collections,
but if you add new object/s - you need to reapply collection visibility.

Feel free to modify if needed.

Also if you want it to be like this


just rename OUTLINER_MT_collection_visibility to OUTLINER_MT_collection
at the bottom in the script file.

6 Likes

Thenks for this addon! Very helpfull in large scenes!

When i execute for example bpy.ops.collection.visibility(shading_type='BOUNDS') from pie menu (Pie menu Editor) i have this error:

Python: Traceback (most recent call last):
  File "C:\Users\radi0n\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\Collection_Visibility.py", line 55, in execute
    collection_names = [col.name for col in bpy.context.selected_ids]
AttributeError: 'Context' object has no attribute 'selected_ids'

location: <unknown location>:-1

In Outliner “Collection” menu works fine.

there is no ‘selected_ids’ outside of the outliner context. OP needs to either poll for context.area.type == 'OUTLINER' or add the ctypes workaround.

1 Like

Sorry, but I know the coding as much as I know sheep shearing …

It’s because it only work if execute from outliner.
I will look what @testure suggested.

But why do you use it in pie from 3d View?
You click on collection in outliner, then move mouse to viewport area and use pie?
Isn’t it quicker then just RMB click on collection?

Ok.
New implementation to work also from 3d View, BUT
instead of use active collection it uses selected objects and use all collection where they located.


Collection_Visibility.py (5.1 KB)

P.S. idn why there is no option “Assign Shortcut” for that menu entries. Anyone know why?

2 Likes

Thank You very much.

Why from 3dview? Im almost all the time use 3dview in full screen mode without any other windows.
With Pie Menu Editor i configured blender that way.

1 Like

Is it possible to set Collection with Links Object (with children) only as bounds without showing children?

I have no idea how to do that, sorry.
Linked collection is like instance of the mesh, you can’t disable visibility in mesh except manually hide faces or vertices of them, in blender case you can only manually disable viewport visibility in original collection for children to not show them in Linked Collection.

Maybe someone have an idea how to implement this…

1 Like

hi,

in 3.0 when i try change collection visibility in edit mode i have this error:

Python: Traceback (most recent call last):
  File "C:\Users\radi0n\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\Collection_Visibility.py", line 79, in execute
    ops.object.select_grouped(extend=True, type='COLLECTION')                        
  File "C:\Blender\Blender3.0\3.0\scripts\modules\bpy\ops.py", line 132, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.object.select_grouped.poll() failed, context is incorrect

location: <unknown location>:-1


Hi,
I will check it out.

Try this quick fix (remove old script via blender and install this one):
Collection_Visibility_0_3_0.py (5.3 KB)

1 Like

Thx for the quick fix!

1 Like

That’s nice, I’m gonna install it.
I actually plan to use this as toggles as well (for keyboard shortcuts). Could you add support for these two toggles both for selected objects and for collections?

  • Bounds/ textured
  • Wires/ textured

Sometimes I would only need to change the current selection’s display mode, that’s why :wink:

I will try to implement this feature.

Thank you!

for selected objects it’s understandable - toggle if wire then textured.
What about collection? Toggle by active object(1) or independent(2)?
For example:
(1) you select objects in two collections and the active selected object have display type wire - then change all objects in this collections to textured OR
(2) switch display type from wire to textured and if textured to wire independently for each object

or for selected objects also use the active selected display type?

Let’s think out loud here, suppose I have a couple of nested collections for which I select at least one object each.

(1) You toggle the active object > all other objects are toggled to the same state as the active object is.

The result is predictable, you toggle all objects in one go, so single step procedure.

(2a). If I toggle all to the same display mode, you could have (A) all to wire or (B) all to textured.

Worst case scenario, there is no way to get all objects to the same type. It goes both ways and is unpredictable with lots of collections/ objects.

(2b). Toggle all objects from Wire to Textured first, if all objects are Textured, toggle to Wire.

Worst case scenario, two step procedure.

(3) Toggle all selected objects to use the active selection display type

If they are all the same type, this wouldn’t do anything.

Understood.
I change it to use active object display type.

@APEC Actually, it is fine the way you had it I think. Let me test first before you do all the work.
I found some issues as well.

Ok.
sorry, found a bug, moment
this is not accounting active object selected

for 3d view and for outliner need to add entries for keymap object.visibility_toggle

Added:
when you said it would be running from outliner it become a little complicated

1 Like