From 2d53c691f59fd1a0cb45a4f90f144f258e9a8340 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 4 Feb 2020 11:55:54 +1100 Subject: [PATCH] Prevent duplicate GlobalIds if the author manually creates a collision --- src/ifcblenderexport/blenderbim/export_ifc.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ifcblenderexport/blenderbim/export_ifc.py b/src/ifcblenderexport/blenderbim/export_ifc.py index 570562e87c..37542d9036 100644 --- a/src/ifcblenderexport/blenderbim/export_ifc.py +++ b/src/ifcblenderexport/blenderbim/export_ifc.py @@ -77,6 +77,7 @@ class IfcParser(): self.selected_products = [] self.selected_spatial_structure_elements = [] + self.global_ids = [] self.product_index = 0 self.product_name_index_map = {} @@ -195,11 +196,15 @@ class IfcParser(): def get_object_attributes(self, obj): attributes = {'Name': self.get_ifc_name(obj.name)} - if obj.BIMObjectProperties.attributes.find('GlobalId') == -1: + global_id_index = obj.BIMObjectProperties.attributes.find('GlobalId') + if global_id_index == -1: global_id = obj.BIMObjectProperties.attributes.add() global_id.name = 'GlobalId' global_id.string_value = ifcopenshell.guid.new() + elif obj.BIMObjectProperties.attributes[global_id_index].string_value in self.global_ids: + obj.BIMObjectProperties.attributes[global_id_index].string_value = ifcopenshell.guid.new() attributes.update({a.name: a.string_value for a in obj.BIMObjectProperties.attributes}) + self.global_ids.append(attributes['GlobalId']) return attributes def get_products(self):