Openings are now placed in their own collection in case they accidentally get placed in the spatial tree

This commit is contained in:
Dion Moult
2021-07-24 21:35:27 +10:00
parent 6660714308
commit fe3ffb7771
2 changed files with 18 additions and 4 deletions
@@ -129,6 +129,8 @@ class AssignClass(bpy.types.Operator):
if product.is_a("IfcElementType"):
self.place_in_types_collection(obj)
elif product.is_a("IfcOpeningElement"):
self.place_in_openings_collection(obj)
elif (
product.is_a("IfcSpatialElement")
or product.is_a("IfcSpatialStructureElement")
@@ -152,6 +154,18 @@ class AssignClass(bpy.types.Operator):
break
break
def place_in_openings_collection(self, obj):
for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]:
if not [c for c in project.children if "IfcOpeningElements" in c.name]:
opening_elements = bpy.data.collections.new("IfcOpeningElements")
project.collection.children.link(opening_elements)
for collection in [c for c in project.children if "IfcOpeningElements" in c.name]:
for user_collection in obj.users_collection:
user_collection.objects.unlink(obj)
collection.collection.objects.link(obj)
break
break
def place_in_spatial_collection(self, obj):
for collection in obj.users_collection:
if collection.name == obj.name: