# Indirect Only check for collections - Full Data path

Why is there no option to copy full data path of the indirect only check in collections? It's possible for "selectable", "disable in renders" but not for "holdout" and "indirect only".

bpy.data.collections["Collection name"].hide_select - this is a full data path for "selectable"

When you hover your mouse over "indirect only" it shows this:

So the full data path would be:

bpy.data.collections["Collection name"].indirect_only


but it isn't as it doesn't work.

I need it for using in this addon: https://blendermarket.com/products/renderstacknode to set it as a property:

Set collection as Indirect Only (ie. = Shadowcatcher) through python? - in this thread someone proposed using the code below:

bpy.context.view_layer.active_layer_collection.indirect_only


And it works but it doesn't take into account the name of the collection, it just uses the active collection which doesn't satisfy me as it would add much manual work to the process.

I think the way it's presented in the outliner is a bit confusing. What you have to understand is Collections have global properties :

• hide_select
• hide_viewport
• hide_render

And view layer properties, which are accessed with a LayerCollection object :

• exclude
• hide_viewport (I know, it's presented as the same path as the monitor icon one, but bear with me)
• holdout
• indirect_only

Global properties are accessed in a straightforward way, ie bpy.data.collections["Collection"].hide_select = True for instance. This will make the collection unselectable across ALL view layers. Same goes for viewport and render visibility.

View layer- related properties are accessed by their relative layer_collection which is a property of one and only one view_layer. Each collection has a related layer_collection object for each view_layer in the current scene. This object is responsible for holding and modifying its view layer properties.

The tricky part is collections don't hold a direct reference to their (theoretically infinite number of) layer_collection counterparts. You have to traverse the entire view layer's layer collections to test against the current collection, and only then can you change its properties. (I'd love to be corrected if there is an easier way).

Note that LayerCollection does have a direct reference to its unique collection object. (layer_coll.collection)

It then becomes really similar to this question.

import bpy

def traverse_tree(t):
yield t
for child in t.children:
yield from traverse_tree(child)

coll_name = "Collection"
layer_coll_master = bpy.context.view_layer.layer_collection

for layer_coll in traverse_tree(layer_coll_master):
if layer_coll.collection.name == coll_name:
layer_coll.indirect_only = False
break


I guess the short answer to your question is, no, you can't change this property with a one-liner expression in python. (Again, please correct me if I'm wrong)

• OK, I understand it, though it's still not very logical to me from a user's point of view. I'm looking for a perfect workflow in my projects and every time I'm close there's a problem but now I'm the closest to the perfect solution. I think I'll create different view layers and access them with the addon, which is also possible and it's not that much more work in my case.
– Graf
Jul 13 '21 at 5:30
• Another solution which I didn't mention is temporarily change the active collection and use bpy.context.view_layer.active_layer_collection.indirect_only as you found out at first, then reverting the active collection back after. But it may have unintended consequences... Jul 13 '21 at 6:20
• Yeah, I though about it but I think I'll stick with a simpler solution for now :). Thank you anyway.
– Graf
Jul 13 '21 at 11:14