I'd like to get all collections in the current scene and can't find a way to do that. I found bpy.data.collections to get all collections stored in the blend and C.scene.collection.children to return the first level of sub-collections. However, I can't find out which collection is linked to each scene. I wonder if there is a simple way like iterating through the objects in context C.scene.objects?
Q: How to get all collections of the current scene?
coll = bpy.context.view_layer.layer_collection.collection– batFINGER Feb 24 '20 at 14:29bpy.context.scene.collectionandbpy.data.collectionsbecause with the second one in my case I am getting some extra collections from the ones that are visible in the outliner. – ttsesm Sep 25 '20 at 08:12bpy.data.collections– batFINGER Sep 25 '20 at 08:25bpy.context.scene.collectionrather thebpy.data.collections. – ttsesm Sep 25 '20 at 08:40context.collectionwould be my suggestion. Or to be sure to be surecontext.collection or scene.collectionUnless I'm creating objects rarely or never usebpy.dataeg if you are interested in an object "Foo"scene.objects.get("Foo")is in the scene, whereasbpy.data.objects.get("Foo")may not be. Similarly with collections. – batFINGER Sep 25 '20 at 08:49