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.
excludeproperty is what you want right? See: How can I exclude a collection from rendering with Python? – brockmann Sep 09 '19 at 17:46