From 68d3771a834e302ab18cfcd695da7c2f5d8937ed Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 24 Jun 2024 18:18:25 +1000 Subject: [PATCH] Change active layer collection when setting a new default container --- src/blenderbim/blenderbim/tool/spatial.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/blenderbim/blenderbim/tool/spatial.py b/src/blenderbim/blenderbim/tool/spatial.py index b047fa9f4e..ebec8cbcfa 100644 --- a/src/blenderbim/blenderbim/tool/spatial.py +++ b/src/blenderbim/blenderbim/tool/spatial.py @@ -815,6 +815,16 @@ class Spatial(blenderbim.core.tool.Spatial): @classmethod def set_default_container(cls, container): bpy.context.scene.BIMSpatialDecompositionProperties.default_container = container.id() + project = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0]) + project_collection = project.BIMObjectProperties.collection + obj = tool.Ifc.get_object(container) + if obj and (collection := obj.BIMObjectProperties.collection): + for layer_collection in bpy.context.view_layer.layer_collection.children: + if layer_collection.collection == project_collection: + for layer_collection2 in layer_collection.children: + if layer_collection2.collection == collection: + bpy.context.view_layer.active_layer_collection = layer_collection2 + break @classmethod def guess_default_container(cls) -> Optional[ifcopenshell.entity_instance]: