Fix bug where toggled openings didn't properly appear in the dedicated opening collection

This commit is contained in:
Dion Moult
2024-09-02 20:14:43 +10:00
parent 9dcb5b103c
commit 1a8be005cf
2 changed files with 17 additions and 14 deletions
+16 -13
View File
@@ -103,7 +103,7 @@ class Collector(bonsai.core.tool.Collector):
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
project_obj.BIMObjectProperties.collection.children.link(collection)
if layer_collection := tool.Blender.get_layer_collection(collection):
layer_collection.hide_viewport = True
cls.set_layer_collection_visibility(layer_collection)
return collection
@classmethod
@@ -147,6 +147,20 @@ class Collector(bonsai.core.tool.Collector):
return
collection.children.link(obj_or_col)
@classmethod
def set_layer_collection_visibility(cls, layer_collection):
name = layer_collection.collection.name
if name in (
"IfcTypeProduct",
"IfcStructuralItem",
"Unsorted",
):
layer_collection.hide_viewport = True
elif name.startswith("IfcAnnotation"):
layer_collection.hide_viewport = True
else:
layer_collection.hide_viewport = False
@classmethod
def reset_default_visibility(cls):
project = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
@@ -154,15 +168,4 @@ class Collector(bonsai.core.tool.Collector):
for layer_collection in bpy.context.view_layer.layer_collection.children:
if layer_collection.collection == project_collection:
for layer_collection2 in layer_collection.children:
name = layer_collection2.collection.name
if name in (
"IfcTypeProduct",
"IfcOpeningElement",
"IfcStructuralItem",
"Unsorted",
):
layer_collection2.hide_viewport = True
elif name.startswith("IfcAnnotation"):
layer_collection2.hide_viewport = True
else:
layer_collection2.hide_viewport = False
cls.set_layer_collection_visibility(layer_collection2)
+1 -1
View File
@@ -456,7 +456,7 @@ class Model(bonsai.core.tool.Model):
ifc_importer.material_creator.load_existing_materials()
ifc_importer.create_generic_elements(set(openings))
for opening_obj in ifc_importer.added_data.values():
bpy.context.scene.collection.objects.link(opening_obj)
tool.Collector.assign(opening_obj, should_clean_users_collection=False)
return ifc_importer.added_data.values()
@classmethod