mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
(IfcPatch) allow user to specify output directory for "SplitByBuildingStorey"
This commit is contained in:
@@ -18,18 +18,21 @@
|
|||||||
|
|
||||||
|
|
||||||
class Patcher:
|
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
|
"""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
|
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
|
format of {i}-{name}.ifc, where {i} is an ascending number starting from
|
||||||
0 and {name} is the name of the storey.
|
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:
|
Example:
|
||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
ifcpatch.execute({"input": model, "recipe": "SplitByBuildingStorey", "arguments": []})
|
ifcpatch.execute({"input": model, "recipe": "SplitByBuildingStorey", "arguments": ["C:/.../output_files"]})
|
||||||
"""
|
"""
|
||||||
self.src = src
|
self.src = src
|
||||||
self.file = file
|
self.file = file
|
||||||
@@ -41,7 +44,7 @@ class Patcher:
|
|||||||
|
|
||||||
storeys = self.file.by_type("IfcBuildingStorey")
|
storeys = self.file.by_type("IfcBuildingStorey")
|
||||||
for i, storey in enumerate(storeys):
|
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)
|
copyfile(self.src, dest)
|
||||||
old_ifc = ifcopenshell.open(dest)
|
old_ifc = ifcopenshell.open(dest)
|
||||||
new_ifc = ifcopenshell.file(schema=self.file.schema)
|
new_ifc = ifcopenshell.file(schema=self.file.schema)
|
||||||
|
|||||||
Reference in New Issue
Block a user