Assigning a LayerCollection (with "Exclude From ViewLayer" on), to ViewLayer active_layer_collection NotWorking

While “Exclude From View Layers” is On:-

XD = bpy.context.view_layer.active_layer_collection.children['Collection']
XD.collection # prompts-back "bpy.data.collections['Collection']"

When I DO
bpy.context.view_layer.active_layer_collection = XD
(With “Exclude From View Layers” ON) It Doesn’t Work. The active_layer_collection is Not Changed
Neither Does This:-
bpy.context.view_layer.active_layer_collection = bpy.context.view_layer.active_layer_collection.children['Collection']

Why? How am I able to Assign Something that’s Excluded from View Layer to XD while I can’t Assign to bpy.context.view_layer.active_layer_collection

I Know that active_layer_collection Can’t be a NONE Value

But The XD Varible is Getting Assigned bpy.context.view_layer.active_layer_collection, Which Makes Me Feel Like, It Should Work what I am trynna do…

Welcome to the forum :slight_smile:

An excluded collection cannot be the active layer collection.

But The XD Varible is Getting Assigned bpy.context.view_layer.active_layer_collection

Not really, you assigned XD from a children of the active layer collection, not the active layer collection itself.

1 Like

Thanks For the Reply… I am New To Scripting :sweat_smile:

Sorry, I mistakenly Wrote that… But The Confusion that I am in is, When A new Blender is Loaded, active_layer_collection isn’t the “Master Collection”, instead it is the Default Children Collection of Master Collection that Blender Gives Us. If someone Just Presses the “Exclude Button” for the Default Collection in ViewLayer, active_layer_collection suddenly changes to Master Collection. Then Why Was it Made Like that For the Default Blender File? Why isn’t Master Collection The Default active_layer_collection?

I don’t really understand you. But the reasoning behind Blender’s default is no longer a Python question I guess :slight_smile:

1 Like