From 1b85928810d8ced9b227f1bd49c671a823820239 Mon Sep 17 00:00:00 2001 From: Vukas Pajic Date: Wed, 8 Feb 2023 10:42:05 +0100 Subject: [PATCH] allow user to specify output directory for "SplitByBuildingStorey" --- src/ifcpatch/ifcpatch/recipes/SplitByBuildingStorey.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ifcpatch/ifcpatch/recipes/SplitByBuildingStorey.py b/src/ifcpatch/ifcpatch/recipes/SplitByBuildingStorey.py index 8ce7f30656..3a48af45b7 100644 --- a/src/ifcpatch/ifcpatch/recipes/SplitByBuildingStorey.py +++ b/src/ifcpatch/ifcpatch/recipes/SplitByBuildingStorey.py @@ -18,18 +18,21 @@ class Patcher: - def __init__(self, src, file, logger): + def __init__(self, src, file, logger, output_dir=None): """Split an IFC model into multiple models based on building storey The new IFC model names will be named after the storey name in the format of {i}-{name}.ifc, where {i} is an ascending number starting from 0 and {name} is the name of the storey. + :param output_dir: Specifies an output directory where the new IFC models will be saved. + :type output_dir: str + Example: .. code:: python - ifcpatch.execute({"input": model, "recipe": "SplitByBuildingStorey", "arguments": []}) + ifcpatch.execute({"input": model, "recipe": "SplitByBuildingStorey", "arguments": ["C:/.../output_files"]}) """ self.src = src self.file = file @@ -41,7 +44,7 @@ class Patcher: storeys = self.file.by_type("IfcBuildingStorey") for i, storey in enumerate(storeys): - dest = "{}-{}.ifc".format(i, storey.Name) + dest = "{}-{}.ifc".format(i, storey.Name) if self.output_dir == None else "{}/{}-{}.ifc".format(self.output_dir,i, storey.Name) copyfile(self.src, dest) old_ifc = ifcopenshell.open(dest) new_ifc = ifcopenshell.file(schema=self.file.schema)