Add support for loading IFCs with aggregated types

This commit is contained in:
Dion Moult
2022-12-17 20:48:05 +11:00
parent efed95615e
commit d34e45fad5
2 changed files with 11 additions and 3 deletions
+9 -1
View File
@@ -1410,7 +1410,11 @@ class IfcImporter:
rel_aggregates += [e.Decomposes[0] for e in self.elements if e.Decomposes] rel_aggregates += [e.Decomposes[0] for e in self.elements if e.Decomposes]
rel_aggregates = set(rel_aggregates) rel_aggregates = set(rel_aggregates)
else: else:
rel_aggregates = [a for a in self.file.by_type("IfcRelAggregates") if a.RelatingObject.is_a("IfcElement")] rel_aggregates = [
a
for a in self.file.by_type("IfcRelAggregates")
if a.RelatingObject.is_a("IfcElement") or a.RelatingObject.is_a("IfcElementType")
]
if len(rel_aggregates) > 10000: if len(rel_aggregates) > 10000:
# More than 10,000 collections makes Blender unhappy # More than 10,000 collections makes Blender unhappy
@@ -1433,6 +1437,10 @@ class IfcImporter:
parent = ifcopenshell.util.element.get_container(aggregate["element"]) parent = ifcopenshell.util.element.get_container(aggregate["element"])
if parent: if parent:
self.collections[parent.GlobalId].children.link(aggregate["collection"]) self.collections[parent.GlobalId].children.link(aggregate["collection"])
continue
if aggregate["element"].is_a("IfcElementType"):
self.type_collection.children.link(aggregate["collection"])
continue
def create_materials(self): def create_materials(self):
for material in self.file.by_type("IfcMaterial"): for material in self.file.by_type("IfcMaterial"):
@@ -178,7 +178,7 @@ class ObjectMaterialData:
icon = "POINTCLOUD_DATA" icon = "POINTCLOUD_DATA"
for item in items or []: for item in items or []:
data = {"id": item.id(), "name": item.Name or "Unnamed", "icon": icon} data = {"id": item.id(), "name": getattr(item, "Name", None) or "Unnamed", "icon": icon}
if item.is_a("IfcMaterialProfile") and not item.Name: if item.is_a("IfcMaterialProfile") and not item.Name:
data["name"] = item.Profile.ProfileName or "Unnamed" data["name"] = item.Profile.ProfileName or "Unnamed"
if item.is_a("IfcMaterialLayer"): if item.is_a("IfcMaterialLayer"):