diff --git a/src/ifcpatch/README.md b/src/ifcpatch/README.md new file mode 100644 index 0000000000..7baafb9b35 --- /dev/null +++ b/src/ifcpatch/README.md @@ -0,0 +1,70 @@ +# ifcpatch + +`ifcpatch` is a little CLI utility and library that lets you run a predetermined +modification on an IFC file, known as a patch recipe. This is great for +distributing little scripts that need to modify an IFC to users who don't know +how to code or aren't interested in knowing the details. + +## Installation + +`ifcpatch` is a simple Python module. No compilation or packaging is necessary. +Just download the `ifcpatch` directory and add it to your Python site packages. +Then, you can run it as a CLI like: + +``` +$ python -m ifcpatch +``` + +If you want something more Unix-like ... + +``` +$ alias ifcpatch='python -m ifcpatch' +``` + +## Usage + +Usage is like any other CLI app. + +``` +$ ifcpatch -h + +usage: __main__.py [-h] -i INPUT [-o OUTPUT] -r RECIPE [-l LOG] + [-a ARGUMENTS [ARGUMENTS ...]] + +Patches IFC files to fix badly formatted data + +optional arguments: + -h, --help show this help message and exit + -i INPUT, --input INPUT + The IFC file to patch + -o OUTPUT, --output OUTPUT + The output file to save the patched IFC + -r RECIPE, --recipe RECIPE + Name of the recipe to use when patching + -l LOG, --log LOG Specify a log file + -a ARGUMENTS [ARGUMENTS ...], --arguments ARGUMENTS [ARGUMENTS ...] + Specify custom arguments to the patch recipe +``` + +Exactly how it is run depends on the recipe. A recipe may require zero or more +arguments which are specific to the recipe. Here's an example which runs the +`ExtractElements` recipe, which, as the same suggests, extracts out elements. +This recipe expects one argument, which is a [filtering +query](https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples#IFC_Query_Syntax). +In this example, we'll extract out all `IfcWall` elements. + +``` +$ ifcpatch -i input.ifc -o output.ifc -r ExtractElements -a ".IfcWall" +``` + +You can also use it as a library. + +``` +import ifcpatch +ifcpatch.execute({ + "input": "input.ifc", + "output": "output.ifc", + "recipe": "ExtractElements", + "arguments": [".IfcWall"], +}) +``` diff --git a/src/ifcpatch/__init__.py b/src/ifcpatch/ifcpatch/__init__.py similarity index 100% rename from src/ifcpatch/__init__.py rename to src/ifcpatch/ifcpatch/__init__.py diff --git a/src/ifcpatch/__main__.py b/src/ifcpatch/ifcpatch/__main__.py similarity index 100% rename from src/ifcpatch/__main__.py rename to src/ifcpatch/ifcpatch/__main__.py diff --git a/src/ifcpatch/make.py b/src/ifcpatch/ifcpatch/make.py similarity index 100% rename from src/ifcpatch/make.py rename to src/ifcpatch/ifcpatch/make.py diff --git a/src/ifcpatch/recipes/ExtractElements.py b/src/ifcpatch/ifcpatch/recipes/ExtractElements.py similarity index 100% rename from src/ifcpatch/recipes/ExtractElements.py rename to src/ifcpatch/ifcpatch/recipes/ExtractElements.py diff --git a/src/ifcpatch/recipes/MergeProject.py b/src/ifcpatch/ifcpatch/recipes/MergeProject.py similarity index 100% rename from src/ifcpatch/recipes/MergeProject.py rename to src/ifcpatch/ifcpatch/recipes/MergeProject.py diff --git a/src/ifcpatch/recipes/Migrate.py b/src/ifcpatch/ifcpatch/recipes/Migrate.py similarity index 100% rename from src/ifcpatch/recipes/Migrate.py rename to src/ifcpatch/ifcpatch/recipes/Migrate.py diff --git a/src/ifcpatch/recipes/OffsetObjectPlacements.py b/src/ifcpatch/ifcpatch/recipes/OffsetObjectPlacements.py similarity index 100% rename from src/ifcpatch/recipes/OffsetObjectPlacements.py rename to src/ifcpatch/ifcpatch/recipes/OffsetObjectPlacements.py diff --git a/src/ifcpatch/recipes/OffsetStoreyElevations.py b/src/ifcpatch/ifcpatch/recipes/OffsetStoreyElevations.py similarity index 100% rename from src/ifcpatch/recipes/OffsetStoreyElevations.py rename to src/ifcpatch/ifcpatch/recipes/OffsetStoreyElevations.py diff --git a/src/ifcpatch/recipes/Optimise.py b/src/ifcpatch/ifcpatch/recipes/Optimise.py similarity index 100% rename from src/ifcpatch/recipes/Optimise.py rename to src/ifcpatch/ifcpatch/recipes/Optimise.py diff --git a/src/ifcpatch/recipes/RecycleNonRootedElements.py b/src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py similarity index 100% rename from src/ifcpatch/recipes/RecycleNonRootedElements.py rename to src/ifcpatch/ifcpatch/recipes/RecycleNonRootedElements.py diff --git a/src/ifcpatch/recipes/RemoveSiteRepresentation.py b/src/ifcpatch/ifcpatch/recipes/RemoveSiteRepresentation.py similarity index 100% rename from src/ifcpatch/recipes/RemoveSiteRepresentation.py rename to src/ifcpatch/ifcpatch/recipes/RemoveSiteRepresentation.py diff --git a/src/ifcpatch/recipes/ResetAbsoluteCoordinates.py b/src/ifcpatch/ifcpatch/recipes/ResetAbsoluteCoordinates.py similarity index 100% rename from src/ifcpatch/recipes/ResetAbsoluteCoordinates.py rename to src/ifcpatch/ifcpatch/recipes/ResetAbsoluteCoordinates.py diff --git a/src/ifcpatch/recipes/ResetSpatialElementLocations.py b/src/ifcpatch/ifcpatch/recipes/ResetSpatialElementLocations.py similarity index 100% rename from src/ifcpatch/recipes/ResetSpatialElementLocations.py rename to src/ifcpatch/ifcpatch/recipes/ResetSpatialElementLocations.py diff --git a/src/ifcpatch/recipes/SetRefElevation.py b/src/ifcpatch/ifcpatch/recipes/SetRefElevation.py similarity index 100% rename from src/ifcpatch/recipes/SetRefElevation.py rename to src/ifcpatch/ifcpatch/recipes/SetRefElevation.py diff --git a/src/ifcpatch/recipes/SplitByBuildingStorey.py b/src/ifcpatch/ifcpatch/recipes/SplitByBuildingStorey.py similarity index 100% rename from src/ifcpatch/recipes/SplitByBuildingStorey.py rename to src/ifcpatch/ifcpatch/recipes/SplitByBuildingStorey.py diff --git a/src/ifcpatch/recipes/__init__.py b/src/ifcpatch/ifcpatch/recipes/__init__.py similarity index 100% rename from src/ifcpatch/recipes/__init__.py rename to src/ifcpatch/ifcpatch/recipes/__init__.py