| 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}") |