From 9005333f539600ae4d3b1e2da23c58f230d270ce Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 27 Feb 2026 15:17:35 +0500 Subject: [PATCH] ifcpatch MergeProjects - make `logger` arg optional --- src/ifcpatch/ifcpatch/recipes/MergeProjects.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ifcpatch/ifcpatch/recipes/MergeProjects.py b/src/ifcpatch/ifcpatch/recipes/MergeProjects.py index 4a06c3d253..9d20164424 100644 --- a/src/ifcpatch/ifcpatch/recipes/MergeProjects.py +++ b/src/ifcpatch/ifcpatch/recipes/MergeProjects.py @@ -16,9 +16,11 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcPatch. If not, see . +from collections.abc import Sequence from logging import Logger from typing import Union +import ifcpatch import ifcopenshell import ifcopenshell.util.element import ifcopenshell.util.geolocation @@ -29,8 +31,13 @@ import ifcpatch from ifcpatch.recipes.SetFalseOrigin import Patcher as SetFalseOrigin -class Patcher: - def __init__(self, file: ifcopenshell.file, logger: Logger, filepaths: list[Union[str, ifcopenshell.file]]): +class Patcher(ifcpatch.BasePatcher): + def __init__( + self, + file: ifcopenshell.file, + logger: Logger | None = None, + filepaths: Sequence[Union[str, ifcopenshell.file]] = (), + ): """Merge two or more IFC models into one Note that other than combining the two (or more) IfcProject elements into @@ -51,8 +58,7 @@ class Patcher: ifcpatch.execute({"input": "input.ifc", "file": model, "recipe": "MergeProjects", "arguments": ["/path/to/model2.ifc"]}) """ - self.file = file - self.logger = logger + super().__init__(file, logger) self.filepaths = filepaths def patch(self): @@ -62,6 +68,8 @@ class Patcher: "replace it with a list of file/filepaths." ) self.filepaths = [self.filepaths] + if len(self.filepaths) == 0: + raise ValueError("At least one file/filepath must be provided to merge with the main model.") for filepath in self.filepaths: if isinstance(filepath, ifcopenshell.file): other = filepath