Main IfcDiff application If you are using IfcDiff as a library, this is the class you should use. :param old: IFC file object for the old model :param new: IFC file object for the new model :param relationships: List of relationships to check. None means that only geometry
| 45 | |
| 46 | |
| 47 | class IfcDiff: |
| 48 | """Main IfcDiff application |
| 49 | |
| 50 | If you are using IfcDiff as a library, this is the class you should use. |
| 51 | |
| 52 | :param old: IFC file object for the old model |
| 53 | :param new: IFC file object for the new model |
| 54 | :param relationships: List of relationships to check. None means that only |
| 55 | geometry is compared. See RELATIONSHIP_TYPE for available relationships. |
| 56 | :param is_shallow: True if you want only the first difference to be listed. |
| 57 | False if you want all differences to be checked. Choosing False means |
| 58 | that comparisons will take longer. |
| 59 | :param filter_elements: An IFC filter query if you only want to compare a |
| 60 | subset of elements. For example: ``IfcWall`` to only compare walls. |
| 61 | |
| 62 | Example:: |
| 63 | |
| 64 | from ifcdiff import IfcDiff |
| 65 | |
| 66 | ifc_diff = IfcDiff("/path/to/old.ifc", "/path/to/new.ifc", "/path/to/diff.json") |
| 67 | ifc_diff.diff() |
| 68 | print(ifc_diff.change_register) |
| 69 | ifc_diff.export() |
| 70 | """ |
| 71 | |
| 72 | added_elements: set[ifcopenshell.entity_instance] |
| 73 | deleted_elements: set[ifcopenshell.entity_instance] |
| 74 | # GlobalIds to changes dictionary. |
| 75 | change_register: dict[str, dict[str, Any]] |
| 76 | |
| 77 | def __init__( |
| 78 | self, |
| 79 | old: ifcopenshell.file, |
| 80 | new: ifcopenshell.file, |
| 81 | relationships: Optional[list[RELATIONSHIP_TYPE]] = None, |
| 82 | is_shallow: bool = True, |
| 83 | filter_elements: Optional[str] = None, |
| 84 | ): |
| 85 | self.old = old |
| 86 | self.new = new |
| 87 | self.change_register = {} |
| 88 | self.representation_ids = {} |
| 89 | self.relationships = relationships or ["geometry"] |
| 90 | self.precision = 1e-4 |
| 91 | self.is_shallow = is_shallow |
| 92 | self.filter_elements = filter_elements |
| 93 | |
| 94 | def diff(self) -> None: |
| 95 | logging.disable(logging.CRITICAL) |
| 96 | |
| 97 | self.precision = self.get_precision() |
| 98 | |
| 99 | if self.filter_elements: |
| 100 | old_elements = set( |
| 101 | e.GlobalId for e in ifcopenshell.util.selector.filter_elements(self.old, self.filter_elements) |
| 102 | ) |
| 103 | new_elements = set( |
| 104 | e.GlobalId for e in ifcopenshell.util.selector.filter_elements(self.new, self.filter_elements) |