|
| 1 | +# ifcclash |
| 2 | + |
| 3 | +`ifcclash` is both a CLI utility and library that lets you perform clash |
| 4 | +detections on and between IFC files. |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +`ifcclash` depends on |
| 9 | +[`hppfcl`](https://github.com/humanoid-path-planner/hpp-fcl) and optionally |
| 10 | +[`bcf`](https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.6.0/src/bcf). Once |
| 11 | +you have the dependencies, the `ifcclash` directory may be added to your Python |
| 12 | +site packages like any other Python module. You can run it as a CLI like: |
| 13 | + |
| 14 | +``` |
| 15 | +$ python -m ifcclash |
| 16 | +``` |
| 17 | + |
| 18 | +If you want something more Unix-like ... |
| 19 | + |
| 20 | +``` |
| 21 | +$ alias ifcclash='python -m ifcclash' |
| 22 | +``` |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +Instructions on what clashes to perform are structured in terms of clash sets. |
| 27 | +Each clash set contains instructions of collisions that we want to perform, and |
| 28 | +can be named so it is easy to distinguish. A typical name would be "Structure |
| 29 | +and Pipes", to describe that we are are detecting collisions between structural |
| 30 | +elements and pipes. |
| 31 | + |
| 32 | +Each clash set may include two groups of objects, named `A` and `B`. This tells |
| 33 | +IfcClash to attempt to find collisions between any object in group `A` with any |
| 34 | +object in group `B`. Group `A` is mandatory, but group `B` is optional. If group |
| 35 | +`B` is not provided, IfcClash will detect all clashes within objects of group |
| 36 | +`A`. |
| 37 | + |
| 38 | +Within group `A` or `B`, you may be define one or more data sources of objects. |
| 39 | +A data source must include a path to the IFC file which the objects come from. |
| 40 | +You may also optionally provide a filter to only include or exclude certain |
| 41 | +objects. If no filter is provided, then all objects will be used to detect |
| 42 | +collisions. |
| 43 | + |
| 44 | +Here's a sample JSON description of a single clash set, with both groups |
| 45 | +defined with data sources. |
| 46 | + |
| 47 | +```json |
| 48 | +[ |
| 49 | + { |
| 50 | + "name": "Clash Set A", |
| 51 | + "a": [ |
| 52 | + { |
| 53 | + "file": "/path/to/one.ifc" |
| 54 | + } |
| 55 | + ], |
| 56 | + "b": [ |
| 57 | + { |
| 58 | + "file": "/path/to/two.ifc" |
| 59 | + "selector": ".IfcWall", |
| 60 | + "mode": "i" |
| 61 | + } |
| 62 | + ] |
| 63 | + }, |
| 64 | + ... |
| 65 | +] |
| 66 | +``` |
| 67 | + |
| 68 | +Once your have your JSON description of your clashes, usage is like any other |
| 69 | +CLI app. |
| 70 | + |
| 71 | +``` |
| 72 | +$ ifcclash -h |
| 73 | +
|
| 74 | +usage: __main__.py [-h] [-o OUTPUT] input |
| 75 | +
|
| 76 | +Clashes geometry between two IFC files |
| 77 | +
|
| 78 | +positional arguments: |
| 79 | + input A JSON dataset describing a series of clashsets |
| 80 | +
|
| 81 | +optional arguments: |
| 82 | + -h, --help show this help message and exit |
| 83 | + -o OUTPUT, --output OUTPUT |
| 84 | + The JSON diff file to output. Defaults to output.json |
| 85 | +``` |
| 86 | + |
| 87 | +In it simplest form, just present your JSON file. |
| 88 | + |
| 89 | +``` |
| 90 | +$ ifcclash clash_sets.json |
| 91 | +$ cat output.json |
| 92 | +``` |
| 93 | + |
| 94 | +You can also use it as a library. |
| 95 | + |
| 96 | +```python |
| 97 | +import sys |
| 98 | +import json |
| 99 | +import logging |
| 100 | +import ifcclash |
| 101 | + |
| 102 | + |
| 103 | +settings = ClashSettings() |
| 104 | +settings.output = "output.json" |
| 105 | +settings.logger = logging.getLogger("Clash") |
| 106 | +settings.logger.setLevel(logging.DEBUG) |
| 107 | +handler = logging.StreamHandler(sys.stdout) |
| 108 | +handler.setLevel(logging.DEBUG) |
| 109 | +settings.logger.addHandler(handler) |
| 110 | +ifc_clasher = Clasher(settings) |
| 111 | +with open(args.input, "r") as clash_sets_file: |
| 112 | + ifc_clasher.clash_sets = json.loads(clash_sets_file.read()) |
| 113 | +ifc_clasher.clash() |
| 114 | +ifc_clasher.export() |
| 115 | +``` |
0 commit comments