New patch to fix duplicate Revit types. See commit message for details.

Types in Revit are secretly duplicated (or more) if they are mirrored or hosted in another object unbeknownst to the user. So what the user thinks is a single construction type in Revit ends up being multiple IFC types. This leads to incorrect results when someone interrogates the IFC file. This is fundamentally an issue in the way Revit handles element mirroring and hosting, so there is no fix on the Revit side, so this workaround mitigates the issue by doing a shallow merge of the type objects.
This commit is contained in:
Dion Moult
2021-07-25 12:00:05 +10:00
parent 8ca6183313
commit 07f19ad80a
@@ -0,0 +1,21 @@
import ifcopenshell
import ifcopenshell.util.element
class Patcher:
def __init__(self, src, file, logger, args=None):
self.src = src
self.file = file
self.logger = logger
self.args = args
def patch(self):
tags = {}
for element in self.file.by_type("IfcTypeObject"):
original_element = tags.get(element.Tag, None)
if original_element:
for inverse in self.file.get_inverse(element):
ifcopenshell.util.element.replace_attribute(inverse, element, original_element)
self.file.remove(element)
else:
tags[element.Tag] = element