Skip to main content

COMPAS IFC

compas_ifc

A front-end data model for the Industry Foundation Classes (IFC), the open BIM exchange standard maintained by buildingSMART International. COMPAS IFC sits between IFC's full schema and the people who need to work with it, exposing a small, intentional API where the schema offers thousands of classes and dozens of relationship patterns.

The toolkit is the open-source artefact described in chapter 4 of Future Data Models for AEC: From Simplicity for Humans to Interoperability by AI (Li Chen, ETH Zürich, 2026). It targets researchers and developers who need to read, analyse, modify, and write IFC data without becoming experts in the schema itself.

What it does

  • Opens any IFC file (IFC2X3, IFC4, or IFC4X3) and exposes its content through one container class and one element class.
  • Materialises the spatial hierarchy as an explicit tree with direct parent/child pointers, so traversal does not require chasing IfcRelContainedInSpatialStructure instances.
  • Materialises non-hierarchical relationships (structural connections, system flows, material associations, geometric dependencies) as a separate graph.
  • Couples geometric representations to executable kernels — the COMPAS core library for primitives and meshes, and OpenCascade (via compas_occ) for B-Rep and NURBS — so volumes, surface areas, and bounding boxes can be computed without leaving Python. Contact and collision detection between elements is handled with a NumPy + Shapely broadphase/narrowphase.
  • Treats every product subclass uniformly through a single GenericElement type, falling back to IfcBuildingElementProxy (with the original type name preserved as ObjectType) for custom or domain-specific elements.
  • Validates element metadata against Pydantic schemas and rejects non-conforming data at the point of insertion.

Architecture (three layers)

┌───────────────────────────────────────────────────────────────────┐
│ Front-end API                                                     │
│   BuildingInformationModel  GenericElement                        │
│   SpatialTree (model.tree)  InteractionGraph (model.graph)        │
└───────────────────────────────────────────────────────────────────┘
                                 ▲
┌───────────────────────────────────────────────────────────────────┐
│ Bidirectional mapping layer                                       │
│   relationship resolution · placement-chain rectification ·       │
│   representation conversion · type normalisation ·                │
│   property serialisation                                          │
└───────────────────────────────────────────────────────────────────┘
                                 ▲
┌───────────────────────────────────────────────────────────────────┐
│ IFC schema interface — IfcOpenShell (IFC2X3 · IFC4 · IFC4X3)      │
└───────────────────────────────────────────────────────────────────┘

Installation

pip install compas_ifc

For development:

git clone https://github.com/compas-dev/compas_ifc.git
cd compas_ifc
pip install -e ".[dev]"

Optional dependencies:

  • compas_occ — high-fidelity B-Rep and NURBS via OpenCascade.
  • compas_viewermodel.show() and model.show_collisions().

Quick start

from compas_ifc.bim import BuildingInformationModel

# Load an existing model
model = BuildingInformationModel("data/Duplex_A_20110907.ifc")

# Walk the spatial hierarchy
for storey in model.storeys:
    print(storey.name)
    for child in storey.children:
        print(f"  - [{child.ifc_type}] {child.name}")

# Query by IFC type or GlobalId
walls = model.get_elements_by_type("IfcWall")
wall = model.get_element_by_global_id("3cUkl32yn9qRSPvBJZ3dB2")

# Computed geometric properties
print(wall.volume, wall.surface_area)

# Save back to disk
model.save("modified.ifc")

Creating a new model from scratch:

from compas.geometry import Box, Frame, Point, Vector
from compas_ifc.bim import BuildingInformationModel

model = BuildingInformationModel.template(schema="IFC4", unit="m")
storey = model.storeys[0]

model.create_wall(
    name="South wall",
    parent=storey,
    geometry=Box(8.0, 0.2, 3.0),
    frame=Frame(Point(0, 0, 0), Vector.Xaxis(), Vector.Yaxis()),
)
model.save("from_scratch.ifc")

Custom elements with declarative validation:

from pydantic import BaseModel, Field
from compas_ifc.bim import BuildingInformationModel
from compas_ifc.validation import Specification

class ConcreteRecipe(BaseModel):
    strength_class: str = Field(pattern=r"^C\d{2}/\d{2}$")
    cement_type: str
    cover_mm: float = Field(gt=0)

model = BuildingInformationModel.template(schema="IFC4", unit="m")
model.specifications = [
    Specification(
        name="Concrete recipe",
        ifc_types=["IfcSlab"],
        required_psets={"ConcreteRecipe": ConcreteRecipe},
    )
]
# Slabs added without a valid ConcreteRecipe pset are rejected at insertion.

Verifying the thesis claims

The complete evaluation suite from appendix A of the thesis lives in thesis/appendix/A/. Run them all and produce a consolidated report with:

conda run -n compas-ifc python thesis/appendix/A/run_all.py

The report is written to thesis/appendix/A/outputs/A-summary.txt.

Project structure

compas_ifc/
├── src/compas_ifc/
│   ├── bim.py             # BuildingInformationModel — entry point
│   ├── element.py         # GenericElement — unified element abstraction
│   ├── factory.py         # ElementFactoryMixin — typed creators + template
│   ├── tree.py            # TreeMixin — IFC import/export, placement rectify
│   ├── interactions.py    # InteractionMixin — graph + connection/collision
│   ├── validation.py      # Specification + Pydantic-based enforcement
│   ├── representations/   # Parametric geometry (Extrusion, Pipe, …)
│   ├── brep/              # TessellatedBrep + viewer plugins
│   ├── algorithms/        # Vectorised contact and collision detection
│   ├── conversions/       # IFC ↔ COMPAS converters
│   ├── entities/          # IfcOpenShell wrappers (back-end implementation)
│   └── file.py            # IFCFile — ifcopenshell adapter
├── tests/                 # pytest suite
├── thesis/appendix/A/     # Reproducible evaluation suite (chapter 4)
├── data/                  # Reference IFC files
├── docs/                  # Sphinx documentation
└── scripts/               # Worked examples

License

MIT. See LICENSE.

Citing

If you use COMPAS IFC in academic work, please cite the thesis:

Chen, L. Future Data Models for AEC: From Simplicity for Humans to Interoperability by AI. Doctoral dissertation, ETH Zürich, 2026.

Contact

Issues and feature requests: https://github.com/compas-dev/compas_ifc/issues. Questions: li.chen@arch.ethz.ch.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compas_ifc-2.1.0.tar.gz (257.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compas_ifc-2.1.0-py3-none-any.whl (272.2 kB view details)

Uploaded Python 3

File details

Details for the file compas_ifc-2.1.0.tar.gz.

File metadata

  • Download URL: compas_ifc-2.1.0.tar.gz
  • Upload date:
  • Size: 257.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for compas_ifc-2.1.0.tar.gz
Algorithm Hash digest
SHA256 32c684d16ff61aa3e5ecc111f909991cafe1b5dfba602f195039fdd0f43b962f
MD5 8aacdd801abcabfc7dc8d50b94648c48
BLAKE2b-256 f7ece51b3c156a8ea26ee2de4a17640b20fe746f66542c8cab1a9404a3808bb0

See more details on using hashes here.

File details

Details for the file compas_ifc-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: compas_ifc-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 272.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for compas_ifc-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 679c0f0a7a937095cf6660c40866a9cecb8f6b949f3fb0cdfd3026f7fa9ec824
MD5 8271af7437ca09842fbddf18239f5f08
BLAKE2b-256 a9adc086a1eee5d369555d09af57a0fc32a08d0f799e25ae2ac1ad277d3e8616

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 files

2.0.0

2 files

1.7.0

2 files

1.6.1

2 files

1.6.0

2 files

1.5.0

2 files

1.4.1

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.6.0

2 files

0.5.1

2 files

0.5.0

2 files

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page