Select Alll object inside All selected collections. Any addons?

So, we select multiple collections with some objects, use command and select all objects inside all those collections. Im pretty sure there should be some addon for this.

I was able to find this one. But it doesnt work for me in 3.1.2, and anyway its not exactly what i was looking for.

p.s. no putting all collections inside another collections is not the solution.

You don’t really need an add-on, just toss this in the simple operator template:

collections = [bpy.data.collections["collection_name"], bpy.data.collections["collection_name1"]]
for collection in collections:
    for obj in collection.all_objects:
        obj.select_set(True)
1 Like

Not sure should there be bpy.data.collections[“collection_name1”]]?
But anyway blender told what “collection_name” key not found.

You gotta replace those collection_name’s with the correct ones from your scene. In his example he put only two collections in the array, but you gotta modify the code so all your collections, with the right names, are in that array.

1 Like

i was think its some internal name, operator or something to get collection.

Changing names in script for get collection to be selected, ugh… :laughing:

This script will select all selected collection children.

import bpy

class SelectCollectionChildren(bpy.types.Operator):
    bl_idname = "outliner.select_collection_children"
    bl_label = "Select Collection Children"
 
    def execute(self, context):
        
        for w in context.window_manager.windows:
            s = w.screen
            for a in s.areas:
                if a.type == "OUTLINER":
                    with context.temp_override(window=w, area=a):
                        selected_collections = [s for s in context.selected_ids if s.rna_type.name == "Collection"]
                        for c in selected_collections:
                            for o in c.all_objects:
                                o.select_set(True)
                    break

        return {'FINISHED'}
 
bpy.utils.register_class(SelectCollectionChildren)

You can run this operator by doing F3 → outliner.select_collection_children.
Note: Don’t forget to run the script in the Text Editor initially to register the add-on.

2 Likes

Thanks, but unfortunately it thrown an error:
line 13, in execute
AttributeError: ‘Context’ object has no attribute ‘temp_override’

Are you stating context elsewhere, such as context = bpy.context? This would confuse/override the method assignments. Maybe try running the code without setting it up as a operator.

import bpy
        
for w in bpy.context.window_manager.windows:
    s = w.screen
    for a in s.areas:
        if a.type == "OUTLINER":
            with bpy.context.temp_override(window=w, area=a):
                selected_collections = [s for s in bpy.context.selected_ids if s.rna_type.name == "Collection"]
                for c in selected_collections:
                    for o in c.all_objects:
                        o.select_set(True)
            break

Im not sure cause im not familiar with python )
What i was try with first code: run from text editro, when run from F3 menu.

With second code i try to run it directly from text editor. It will throw an:
line 7, in
AttributeError: ‘Context’ object has no attribute ‘temp_override’

Ah shucks, I just noticed in your original post that you stated you’re still on Blender 3.1.2. context.temp_override was added in Blender 3.2+.

Solution, I’ll try to implement context override without that function for backwards compatibility. If no reply till then, I’ll simply edit my message here. Sorry for not catching your maximum version statement earlier.

@SoundDifferent I wasn’t able to get the older API to work, even in pre-Blender 3.2 versions. Is it possible you can upgrade to a Blender 3.2+ version instead? I believe that’ll solve your issue.

Hello. Thanks, but i temporarily use workaround with simple scripts with selecting all with specific postfixpostfix. Still want ability to select entire collection, but upgrading blender are always pain for me.

Might I ask which part is difficult in particular?

There is a delete hierarchy option that works on multiple collections, too bad there isn’t a select hierarchy

My blender is heavily customized in terms of hotkeys. Its not a problem to simply export/import hotkeys, but the problems start in addons where i disable/change some hotkeys settings.
Like i disable everything for hardops, disable/change something in meshtools addons, some checkboxes enabled/disabled in other addons.
Those tiny fine tunings of hotkeys and UI are ended up in a pretty big list which im doesnt even remember, i.e. i will remember what “that was different” but only when i see it. So every time i update blender and start working i find what something needs to be changed to be as same as in previous blender. In the end its a lot of time wasting on UI tuning, not the modelind.

This is why I only use stock Blender with 2.79 hotkeys and no addons :wink: I can work anywhere Blender runs

But… why can’t you just copy/paste setting files from your previous Blender’s AppData to your current Blender’s AppData? Compatibility shouldn’t break. As it’s just saved add-on or User Preference settings. Not blend data.

Im not sure its really works. I was trying this approach one time and some addons start to throw an errors. Im not really sure what it was because of settings copy/paste.
And anyway there’s always a chance to break compatibility for some addons.