Optimise import and editing for files with lots of aggregations

This commit is contained in:
Dion Moult
2020-12-21 10:44:14 +11:00
parent b0bd027f84
commit 1a48343bcb
2 changed files with 6 additions and 17 deletions
@@ -1308,18 +1308,10 @@ class IfcImporter:
except: except:
# Occurs when reloading a project # Occurs when reloading a project
pass pass
for collection in ( project_collection = bpy.context.view_layer.layer_collection.children[self.project["blender"].name]
bpy.context.view_layer.layer_collection.children[self.project["blender"].name] project_collection.children[self.aggregate_collection.name].hide_viewport = True
.children[self.aggregate_collection.name] project_collection.children[self.opening_collection.name].hide_viewport = True
.children project_collection.children[self.type_collection.name].hide_viewport = True
):
collection.hide_viewport = True
bpy.context.view_layer.layer_collection.children[self.project["blender"].name].children[
self.opening_collection.name
].hide_viewport = True
bpy.context.view_layer.layer_collection.children[self.project["blender"].name].children[
self.type_collection.name
].hide_viewport = True
def create_presentation_layers(self): def create_presentation_layers(self):
for assignment in self.file.by_type("IfcPresentationLayerAssignment"): for assignment in self.file.by_type("IfcPresentationLayerAssignment"):
@@ -2265,7 +2265,6 @@ class CreateAggregate(bpy.types.Operator):
project.collection.children.link(aggregates) project.collection.children.link(aggregates)
for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]: for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]:
aggregate_collection.collection.children.link(aggregate) aggregate_collection.collection.children.link(aggregate)
aggregate_collection.children[aggregate.name].hide_viewport = True
break break
break break
for obj in bpy.context.selected_objects: for obj in bpy.context.selected_objects:
@@ -2296,9 +2295,7 @@ class EditAggregate(bpy.types.Operator):
bpy.context.view_layer.objects[obj.name].hide_viewport = True bpy.context.view_layer.objects[obj.name].hide_viewport = True
for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]: for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]:
for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]: for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]:
for aggregate in [c for c in aggregate_collection.children if c.name == obj.instance_collection.name]: aggregate_collection.hide_viewport = False
aggregate.hide_viewport = False
break
return {"FINISHED"} return {"FINISHED"}
@@ -2312,8 +2309,8 @@ class SaveAggregate(bpy.types.Operator):
names = [c.name for c in obj.users_collection] names = [c.name for c in obj.users_collection]
for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]: for project in [c for c in bpy.context.view_layer.layer_collection.children if "IfcProject" in c.name]:
for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]: for aggregate_collection in [c for c in project.children if "Aggregates" in c.name]:
aggregate_collection.hide_viewport = True
for collection in [c for c in aggregate_collection.children if c.name in names]: for collection in [c for c in aggregate_collection.children if c.name in names]:
collection.hide_viewport = True
aggregate = collection.collection aggregate = collection.collection
break break
if not aggregate: if not aggregate: