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_viewer — model.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.

Metadata

Release files for compas-ifc 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compas-ifc 2.1.0
File Size Uploaded
compas_ifc-2.1.0.tar.gz 257.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for compas-ifc 2.1.0
File Interpreter ABI Platform
compas_ifc-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 530.1 kB

Release files / compas_ifc-2.1.0.tar.gz

Download URL compas_ifc-2.1.0.tar.gz
Size 257.9 kB
Tags Source
SHA-256 checksum
How to use checksums
32c684d16ff61aa3e5ecc111f909991cafe1b5dfba602f195039fdd0f43b962f
BLAKE2b-256 checksum
How to use checksums
f7ece51b3c156a8ea26ee2de4a17640b20fe746f66542c8cab1a9404a3808bb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / compas_ifc-2.1.0-py3-none-any.whl

Download URL compas_ifc-2.1.0-py3-none-any.whl
Size 272.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
679c0f0a7a937095cf6660c40866a9cecb8f6b949f3fb0cdfd3026f7fa9ec824
BLAKE2b-256 checksum
How to use checksums
a9adc086a1eee5d369555d09af57a0fc32a08d0f799e25ae2ac1ad277d3e8616
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page