From 0ef683013a01fc7900511df3e23c515fdb4a60b7 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 30 Apr 2024 16:53:35 +0500 Subject: [PATCH] RegenerateGlobalIds - more informative fixing duplicates --- src/ifcpatch/ifcpatch/recipes/RegenerateGlobalIds.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ifcpatch/ifcpatch/recipes/RegenerateGlobalIds.py b/src/ifcpatch/ifcpatch/recipes/RegenerateGlobalIds.py index 9556c38544..947efbfa1a 100644 --- a/src/ifcpatch/ifcpatch/recipes/RegenerateGlobalIds.py +++ b/src/ifcpatch/ifcpatch/recipes/RegenerateGlobalIds.py @@ -54,18 +54,27 @@ class Patcher: def patch(self): if self.only_duplicates: + duplicates = 0 + invalid_ids = 0 + guids = set() for element in self.file.by_type("IfcRoot"): if element.GlobalId in guids: element.GlobalId = ifcopenshell.guid.new() + duplicates += 1 elif len(element.GlobalId) != 22 or element.GlobalId[0] not in "0123": element.GlobalId = ifcopenshell.guid.new() + invalid_ids += 1 else: try: ifcopenshell.guid.expand(element.GlobalId) except: element.GlobalId = ifcopenshell.guid.new() + invalid_ids += 1 guids.add(element.GlobalId) + + print("Replaced %s duplicate GlobalIds" % duplicates) + print("Replaced %s invalid GlobalIds" % invalid_ids) else: for element in self.file.by_type("IfcRoot"): element.GlobalId = ifcopenshell.guid.new()