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)
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.
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.
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â
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.