From 147216cb7b5ce1d3f5644c8dbc7da577296fefc1 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 4 Sep 2022 22:22:41 +1000 Subject: [PATCH] Revert "Fix bug where IFC data types were hashed as the same value in RecycleNonRootedElements IfcPatch recipe" This reverts commit 3be8e4f1cead56eefc083b484aa95b9b0293423a. --- .../recipes/RecycleNonRootedElements.py | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py b/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py index 48b6361b46..ac3160837f 100644 --- a/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py +++ b/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py @@ -1,3 +1,4 @@ + # IfcPatch - IFC patching utiliy # Copyright (C) 2020, 2021 Dion Moult # @@ -19,7 +20,6 @@ from collections import deque import ifcopenshell.util.element - class Patcher: def __init__(self, src, file, logger, args=None): self.src = src @@ -31,16 +31,9 @@ class Patcher: deleted = [] hashes = {} for element in self.file: - if element.is_a("IfcRoot"): + if element.is_a('IfcRoot'): continue - h = hash( - tuple( - [ - a.wrappedValue if isinstance(a, ifcopenshell.entity_instance) and not a.id() else a - for a in element - ] - ) - ) + h = hash(tuple(element)) if h in hashes: for inverse in self.file.get_inverse(element): ifcopenshell.util.element.replace_attribute(inverse, element, hashes[h]) @@ -49,13 +42,13 @@ class Patcher: hashes[h] = element deleted.sort() deleted_q = deque(deleted) - new = "" - for line in self.file.wrapped_data.to_string().split("\n"): + new = '' + for line in self.file.wrapped_data.to_string().split('\n'): try: - if int(line.split("=")[0][1:]) != deleted_q[0]: - new += line + "\n" + if int(line.split('=')[0][1:]) != deleted_q[0]: + new += (line + '\n') else: deleted_q.popleft() except: - new += line + "\n" + new += (line + '\n') self.file = new