3
$\begingroup$

Hello Im working on really big project and I need to exclude all collections from layerand reverse using script I tried this

import bpy

coll = bpy.data.collections
for c in coll:
   c.exclude = False

But it doesnt seem to work, any ideas where it went wrong or how to solve my problem? Any help is appreciated.

$\endgroup$

1 Answer 1

5
$\begingroup$

You need to use refence from view_layer.layer_collection:

import bpy
   
vl_colls = bpy.context.view_layer.layer_collection.children

# toggle
for coll in vl_colls:
    coll.exclude = not coll.exclude

Layer collection vs Collection:

reference

![](outliner.png)

Properties of LayerCollection(bpy_struct):

![](layercoll%20props.png)

  • Exclude: .exclude
  • Hide in Viewport: .hide_viewport
  • Holdout: .holdout
  • Indirect Only: .indirect_only

Accessed through bpy.context.view_layer.layer_collection.children

Properties of Collection(ID):

![](coll%20props.png)

  • Disable Selection: .hide_select
  • Disable in Viewport: .hide_viewport
  • Disable in Render: .hide_render

Accessed through bpy.data.collections

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.