Skip to main content

ifc2duckdb

Convert IFC files to DuckDB format for fast analysis and querying of Building Information Modeling (BIM) data.

Python Version License Code style: black

Features

  • Fast Conversion: Convert IFC files to DuckDB format for high-performance querying
  • Full Schema Support: Create complete IFC schema tables or only those present in the file
  • Geometry Support: Extract and store 3D geometry data with materials
  • Property Sets: Include IFC property set data
  • Inverse Relationships: Store entity relationships for complex queries
  • Command Line Interface: Easy-to-use CLI for batch processing
  • Python API: Programmatic access for integration into larger workflows

Installation

From PyPI (recommended)

pip install ifc2duckdb

From source

git clone https://github.com/chuongmep/ifc-2-duckdb.git
cd ifc-2-duckdb
pip install -e .

Development installation

git clone https://github.com/chuongmep/ifc-2-duckdb.git
cd ifc-2-duckdb
pip install -e ".[dev]"

Requirements

  • Python 3.10+
  • ifcopenshell >= 1.0.0
  • duckdb >= 0.7.0
  • numpy >= 1.20.0
  • ifcpatch >= 0.1.0

Quick Start

Command Line Usage

# Basic conversion
ifc2duckdb input.ifc output.duckdb

# With options
ifc2duckdb input.ifc --database output.duckdb --no-geometry --verbose

# Help
ifc2duckdb --help

Python API Usage

import ifc2duckdb
import ifcopenshell

# Open IFC file
ifc_file = ifcopenshell.open("racbasicsampleproject.ifc")

# Create patcher with default settings
patcher = ifc2duckdb.Patcher(
    ifc_file,
    database="output.duckdb"
)

# Convert to DuckDB
patcher.patch()

# Get output path
output_path = patcher.get_output()
print(f"Database created at: {output_path}")

Advanced Usage

import ifc2duckdb
import ifcopenshell

# Open IFC file
ifc_file = ifcopenshell.open("racbasicsampleproject.ifc")

# Create patcher with custom settings
patcher = ifc2duckdb.Patcher(
    ifc_file,
    database="output.duckdb",
    full_schema=False,           # Only create tables for classes in the file
    is_strict=True,              # Strict data type validation
    should_expand=True,          # Expand entity lists into separate rows
    should_get_inverses=True,    # Include inverse relationships
    should_get_psets=True,       # Include property set data
    should_get_geometry=True,    # Include geometry data
    should_skip_geometry_data=False  # Include geometry for representation tables
)

# Convert to DuckDB
patcher.patch()

Database Schema

The converted DuckDB database contains several types of tables:

Core Tables

  • id_map: Maps IFC entity IDs to their class names
  • metadata: Contains IFC file metadata (schema, preprocessor info)

IFC Entity Tables

  • One table per IFC class (e.g., IfcWall, IfcDoor, IfcWindow)
  • Each table contains all attributes of the IFC entity
  • Primary key is ifc_id (the IFC entity ID)

Geometry Tables

  • shape: Contains placement and transformation data
  • geometry: Contains mesh data (vertices, edges, faces, materials)

Property Set Tables

  • psets: Contains property set data in key-value format

Querying Examples

-- Find all walls
SELECT * FROM "IfcWall";

-- Find walls with specific properties
SELECT w.*, p.name, p.value 
FROM "IfcWall" w
JOIN psets p ON w.ifc_id = p.ifc_id
WHERE p.pset_name = 'Pset_WallCommon';

-- Get geometry for all elements
SELECT s.*, g.verts, g.faces
FROM shape s
JOIN geometry g ON s.geometry = g.id;

-- Find elements by material
SELECT s.ifc_id, g.materials
FROM shape s
JOIN geometry g ON s.geometry = g.id
WHERE g.materials LIKE '%concrete%';

Development

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=ifc2duckdb --cov-report=html

# Run specific test file
pytest tests/test_patcher.py

Code Formatting

# Format code
black ifc2duckdb tests
isort ifc2duckdb tests

# Check formatting
black --check ifc2duckdb tests
isort --check-only ifc2duckdb tests

Type Checking

mypy ifc2duckdb --ignore-missing-imports

Linting

flake8 ifc2duckdb tests

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and linting (make test lint)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

This project is licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later) - see the LICENSE file for details.

Acknowledgments

References

Metadata

Release files for ifc2duckdb 0.1.2

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

Source distribution (sdist)

Source distribution for ifc2duckdb 0.1.2
File Size Uploaded
ifc2duckdb-0.1.2.tar.gz 844.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ifc2duckdb 0.1.2
File Interpreter ABI Platform
ifc2duckdb-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 857.5 kB

Release files / ifc2duckdb-0.1.2.tar.gz

Download URL ifc2duckdb-0.1.2.tar.gz
Size 844.8 kB
Tags Source
SHA-256 checksum
How to use checksums
96a3c2a9f7f97983aa0a261143cf31dccfc7505e1b537f43d90cfe0a42d1fe05
BLAKE2b-256 checksum
How to use checksums
3e3e9514c0da549c0acad6fb56e987d0f1db22b1683be0237bd644775a7f5c31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / ifc2duckdb-0.1.2-py3-none-any.whl

Download URL ifc2duckdb-0.1.2-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36306fbbb71f8564d7019b9c6c2e548b8fc034c73adc384b02558d57071d2965
BLAKE2b-256 checksum
How to use checksums
c6c2a3fa952e759a71d9d6cc5ba8b67d80e0b7d2f4d22e3b549bd70c991069ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.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