This commit is contained in:
Andrej730
2024-11-08 11:04:18 +05:00
parent 1d3ca475d9
commit fe8c396e12
4 changed files with 17 additions and 99 deletions
@@ -27,7 +27,9 @@ from logging import Logger
class Patcher:
def __init__(self, src: str, file: ifcopenshell.file, logger: Logger, filepaths: Union[str, ifcopenshell.file]):
def __init__(
self, src: str, file: ifcopenshell.file, logger: Logger, filepaths: list[Union[str, ifcopenshell.file]]
):
"""Merge two or more IFC models into one
Note that other than combining the two (or more) IfcProject elements into
@@ -40,7 +42,7 @@ class Patcher:
:param filepaths: The filepath(s) of the second (, third, ...) IFC model
to merge into the first. The first model is already specified as the
input to IfcPatch.
:type filepaths: Union[str, ifcopenshell.file]
:type filepaths: list[Union[str, ifcopenshell.file]]
:filter_glob filepaths: *.ifc;*.ifczip;*.ifcxml
Example:
@@ -60,10 +62,11 @@ class Patcher:
other = filepath
else:
other = ifcopenshell.open(filepath)
assert isinstance(other, ifcopenshell.file)
self.merge(other)
def merge(self, other):
def merge(self, other: ifcopenshell.file) -> None:
if (main_unit := self.get_unit_name(self.file)) != self.get_unit_name(other):
other = ifcopenshell.util.unit.convert_file_length_units(other, main_unit)
@@ -128,7 +131,7 @@ class Patcher:
length_unit = ifcopenshell.util.unit.get_project_unit(ifc_file, "LENGTHUNIT")
return ifcopenshell.util.unit.get_full_unit_name(length_unit)
def reuse_existing_contexts(self):
def reuse_existing_contexts(self) -> None:
to_delete = set()
for added_context in self.added_contexts: