Optimise aggregate creation on large file imports

This commit is contained in:
Dion Moult
2021-02-24 13:49:06 +11:00
parent eeb27bb1c7
commit 3bee746f49
@@ -1189,16 +1189,26 @@ class IfcImporter:
obj = bpy.data.objects.new("{}/{}".format(element.is_a(), element.Name), None)
self.link_element(element, obj)
self.place_object_in_spatial_tree(element, obj)
container_collection = self.get_aggregate_collection(element)
collection = bpy.data.collections.new(obj.name)
obj.users_collection[0].children.link(collection)
obj.users_collection[0].objects.unlink(obj)
container_collection.children.link(collection)
collection.objects.link(obj)
self.aggregates[element.GlobalId] = obj
self.aggregate_collections[rel_aggregate.id()] = collection
def get_aggregate_collection(self, element):
if hasattr(element, "ContainedInStructure") and element.ContainedInStructure:
container = element.ContainedInStructure[0].RelatingStructure
elif hasattr(element, "Decomposes") and element.Decomposes:
container = element.Decomposes[0].RelatingObject
if container.is_a("IfcSpace"):
return self.get_aggregate_collection(container)
return self.spatial_structure_elements[container.GlobalId]["blender"]
def create_openings_collection(self):
self.opening_collection = bpy.data.collections.new("IfcOpeningElements")
self.project["blender"].children.link(self.opening_collection)