Fix bug where aggregate creation doesn't work if the aggregates collection doesn't exist

This commit is contained in:
Dion Moult
2020-08-15 17:34:13 +10:00
parent c359e35747
commit bd02c8e34b
@@ -1763,6 +1763,9 @@ class CreateAggregate(bpy.types.Operator):
aggregate = bpy.data.collections.new('IfcRelAggregates/{}'.format(
bpy.context.scene.BIMProperties.aggregate_class))
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 'Aggregates' in c.name]:
aggregates = bpy.data.collections.new('Aggregates')
project.collection.children.link(aggregates)
for aggregate_collection in [c for c in project.children if 'Aggregates' in c.name]:
aggregate_collection.collection.children.link(aggregate)
aggregate_collection.children[aggregate.name].hide_viewport = True