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.