MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / patch

Method patch

src/ifcpatch/ifcpatch/recipes/MergeStyles.py:44–57  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

42 super().__init__(file, logger)
43
44 def patch(self):
45 for ifc_class in ("IfcColourRgb", "IfcSurfaceStyleShading", "IfcPresentationStyle"):
46 uniques = {}
47 i = 0
48 for element in self.file.by_type(ifc_class):
49 ifc_class = element.is_a()
50 key = "-".join([str(a) for a in element])
51 if unique := uniques.get(ifc_class, {}).get(key, None):
52 ifcopenshell.util.element.replace_element(element, unique)
53 self.file.remove(element)
54 i += 1
55 else:
56 uniques.setdefault(ifc_class, {})[key] = element
57 print(f"Replaced {i} {ifc_class}")

Callers

nothing calls this directly

Calls 7

printFunction · 0.85
setdefaultMethod · 0.80
by_typeMethod · 0.45
is_aMethod · 0.45
joinMethod · 0.45
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected