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"): if product.is_a("IfcElementType"):
self.place_in_types_collection(obj) self.place_in_types_collection(obj)
elif product.is_a("IfcOpeningElement"):
self.place_in_openings_collection(obj)
elif ( elif (
product.is_a("IfcSpatialElement") product.is_a("IfcSpatialElement")
or product.is_a("IfcSpatialStructureElement") or product.is_a("IfcSpatialStructureElement")
@@ -152,6 +154,18 @@ class AssignClass(bpy.types.Operator):
break break
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): def place_in_spatial_collection(self, obj):
for collection in obj.users_collection: for collection in obj.users_collection:
if collection.name == obj.name: if collection.name == obj.name:
@@ -34,7 +34,7 @@ class json_logger:
self.instance = instance self.instance = instance
def log(self, level, message, *args, **kwargs): def log(self, level, message, *args, **kwargs):
self.statements.append(log_entry_type(level, message % args, kwargs.get('instance'))._asdict()) self.statements.append(log_entry_type(level, message % args, kwargs.get("instance"))._asdict())
def __getattr__(self, level): def __getattr__(self, level):
return functools.partial(self.log, level, instance=self.instance) return functools.partial(self.log, level, instance=self.instance)