1
$\begingroup$

Is there any way to logically check the state of each collection's primary checkbox (the one to the left of its name in the outliner)?

When the box is toggled, the info panel shows "bpy.context.scene.exclude = True/False", but that doesn't make sense, since it is a collection being excluded, not the entire scene? Also, there doesn't appear to be any "exclude" member mentioned for collections in the docs.

When one of these are disabled, some exporters avoid exporting their objects, which is useful. But I believe they are pulling this off by selecting ALL objects, which excludes any in unchecked collections.

Does anyone know how to read this value correctly?

Edit: There is a similar question here How can I exclude a collection from rendering with Python? And the answers to this question also answer this question, but the questions are not the same. The checkbox in question is not specific to rendering. It excludes the object from the view layer (view-port, selections, etc). In addition, there is a specific toggle for render exclusion at LayerCol.Collection.hide_render.

$\endgroup$
4
  • 1
    $\begingroup$ The exclude property is what you want right? See: How can I exclude a collection from rendering with Python? $\endgroup$
    – brockmann
    Sep 9, 2019 at 17:46
  • $\begingroup$ It looks like it. But when I try to access collection.exclude, I get an error: "AttributeError: 'Collection' object has no attribute 'exclude'" ... I also cannot find exclude in the 2.8 docs. Maybe there is a version difference? Or possibly because I'm confusing two types? My collection reference comes from the bpy.context.scene.collection.children list. $\endgroup$
    – Robert
    Sep 9, 2019 at 17:54
  • $\begingroup$ Looks like I need to use bpy.context.view_layer.layer_collection and iterate its children instead of the scene's master collection. Is that right? I didn't even realize LayerCollection existed until now. $\endgroup$
    – Robert
    Sep 9, 2019 at 18:04
  • 2
    $\begingroup$ Yes, it worked. Thank you again for your help. The other question is titled as "from rendering", and there is a specific toggle for render exclusion. which makes it appear unrelated. This checkbox excludes it from the view-port, from selections, etc. It excludes it from pretty much everything. $\endgroup$
    – Robert
    Sep 9, 2019 at 18:13

0

Browse other questions tagged .