Change active layer collection when setting a new default container

This commit is contained in:
Dion Moult
2024-06-24 18:18:25 +10:00
parent 80349d70d8
commit 68d3771a83
+10
View File
@@ -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]: