The IFC Data Checker can validate rules on an ifc model.
Project description
IFC Data Checker
IFC Data Checker is a tool to validate rules on IFC models. To do so, the IFC Data Checker needs a rules file and an IFC model. The rules file has to match the rules specification in the report of the bachelor thesis of the IFC Data Checker. The IFC model need to be of version 2x3 or version 4.
Installation:
pip install ifc-data-checker
Or clone this repository and install the dependencies
pip install -r requirements.txt
Add IfcOpenShell Python
To run the IFC Data Checker, you need to install the python package IfcOpenShell. IT need to fit your machine environment regarding:
- the Python version
- the os (Windows, Linux , Mac)
- the os flavor (32bit or 64bit)
To install IfcOpenShell, you need to do the following steps:
- Go to ifcopenshell.org/python and download the matching IfcOpenShell. Use the latest IfcOpenShell version.
- Extract the downloaded file and paste the
ifcopenshell
folder to the directorysite-packages
of the python installation. The folder need to be calledifcopenshell
.- On Linux e.g.
/usr/local/lib/python3.8/site-packages/
- On Windows e.g. in the python installation folder and then
\Lib\site-packages\
- On Linux e.g.
If IfcOpenShell not matching your machine environment, then it will trow an exception like:
ImportError: IfcOpenShell not built for 'windows\64bit\python3.8'
Run the IFC Data Checker
python ifc_data_checker ./path/to/rules-file.yml ./path/to/ifc-model.ifc
GitHub Repository example:
python ifc_data_checker "./rulesfiles/PredefinedType for IfcWall.yml" "./ifcfiles/Duplex-A.ifc"
Usage:
usage: ifc_data_checker [-h] [--report-file] [--no-rulesfile-validation] rules ifc
positional arguments:
rules The path to the rules file.
ifc The path to the ifc file.
optional arguments:
-h, --help show this help message and exit
--report-file Create a validation report file, instead of showing the validation report on the console.
--no-rulesfile-validation
Disable validation of the rules file.
Contribute
You are invited to participate on the IFC Data Checker.
Python Style Guide
The IFC Data Checker follows the Python Style Guide from Google
The source code documentation follows the Google Style. This example helps to follow the Google Style.
Extend Constraint Component
The following 4 steps are to extend the IFC Data Checker for a new Constraint Component.
-
Step
Add a new class in the Python module
ifc_data_checker/constraints.py
. Use the following template and consider the comments.class NewConstraint(ConstraintComponent): """Class description""" yaml_keys = tuple(["new"]) """Set the yaml keys for the new constraint""" def __init__(self, definition: dict, ifc_instance): """Constructor""" super().__init__(definition, ifc_instance) self.potentially_new_attribute = None def validate(self): """Validates. The attribute self.validation_information need to be set.""" def report(self) -> List[str]: """Reports. Return a list of valiation results messages""" return [str(self.validation_information)] def __eq__(self, other): """Equals all the attributes""" if not isinstance(other, NewConstraint): return False return (self.definition == other.definition and self.ifc_instance == other.ifc_instance and self.validation_information == other.validation_information and self.potentially_new_attribute == other.potentially_new_attribute)
-
Step
Add the Name of the class in the yaml file
ifc_data_checker/config.yml
.constraints: - Constraint - SetGroup - AndGroup - OrGroup - NewConstraint
-
Step
Write unit and integration tests for the new constraint component. To do so, add a new Python module under
tests/constraints
. This new test class should inherit fromtests.constraints.constraint_component_test.TestConstraintComponent.TestParameterValidation
. After that, set the attributeconstraint_component_class
anddefault_constraint_component
on the new test class.Now you are ready to implement the test cases. You can have a look at the existing test cases and write the test cases analogously.
The new Python test module should be in the test report. For that, add the Python test module in the Python module
tests/suite.py
analogously as the others. -
Step
The new constraint component need to add to the
rules.schema.json
, to be an accepted constraint component. To do so add the JSON schema of the new constraint component in the JSON schema filerules.schema.json
under definitions -> constraint -> oneOf. Read the JSON schema specification to create an JSON Schema. Here is an example."definitions": { "constraint": { "oneOf": [ … { "type": "object", "properties": { "new": { "type": "string" } }, "required": [ "new" ], "additionalItems": false }, …
To extend an new path operator or an new constraint check, the steps are analogously to the steps of the constraint component.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ifc-data-checker-1.0.1.tar.gz
.
File metadata
- Download URL: ifc-data-checker-1.0.1.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de6c4927ac8ef0c7d07b3ae87ed94afee658c05a39833ee53f94ecf5ad4eaf1f |
|
MD5 | ea52c4a1abd074c916cab3d0634b469a |
|
BLAKE2b-256 | 2a76abf8e23aa4def55d6d0b35639a75743327f3638a3cc0d726f608dcf76d11 |
File details
Details for the file ifc_data_checker-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: ifc_data_checker-1.0.1-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8150a30f65f0665020b34c3c527667f770897594ab8a18e175b514075066d51 |
|
MD5 | a8bb66e36cc3b801248ab08deb8f0c2c |
|
BLAKE2b-256 | 100fdd652974893e1767790ae77bfd1b88364b98400bd519d2968c884748f49f |