ifc2duckdb


Nameifc2duckdb JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryConvert IFC files to DuckDB format for fast analysis and querying
upload_time2025-09-14 15:40:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords ifc duckdb building-information-modeling bim database conversion
VCS
bugtrack_url
requirements ifcopenshell duckdb numpy ifcpatch
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ifc2duckdb

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

[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-LGPL--3.0--or--later-green.svg)](https://spdx.org/licenses/LGPL-3.0-or-later.html)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

![](./docs/ifc2duckdb.png)

## 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)

```bash
pip install ifc2duckdb
```

### From source

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

### Development installation

```bash
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

```bash
# Basic conversion
ifc2duckdb input.ifc output.duckdb

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

# Help
ifc2duckdb --help
```

### Python API Usage

```python
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

```python
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

```sql
-- 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

```bash
# Run all tests
pytest

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

# Run specific test file
pytest tests/test_patcher.py
```

### Code Formatting

```bash
# Format code
black ifc2duckdb tests
isort ifc2duckdb tests

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

### Type Checking

```bash
mypy ifc2duckdb --ignore-missing-imports
```

### Linting

```bash
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](LICENSE) file for details.

## Acknowledgments

- Based on the [Ifc2Sql](https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py) recipe from IfcOpenShell
- Inspired by the [XbimEssentials](https://github.com/xBimTeam/XbimEssentials) project
- Built on top of [IfcOpenShell](https://ifcopenshell.org/) and [DuckDB](https://duckdb.org/)

## References

- [IfcOpenShell Documentation](https://docs.ifcopenshell.org/)
- [IfcPatch Documentation](https://docs.ifcopenshell.org/ifcpatch.html)
- [DuckDB Documentation](https://duckdb.org/docs/)
- [OSArch Community Discussion](https://community.osarch.org/discussion/1535/ifc-stored-as-sqlite-and-mysql)
- [DuckDB Cloud Storage](https://duckdb.org/docs/stable/guides/network_cloud_storage/duckdb_over_https_or_s3.html)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ifc2duckdb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "chuongmep <chuongpqvn@gmail.com>",
    "keywords": "ifc, duckdb, building-information-modeling, bim, database, conversion",
    "author": null,
    "author_email": "chuongmep <chuongpqvn@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/75/00/e17448be7e24cf07276a225e8bad6b5c682b16a0ca909a5ac4edc7336639/ifc2duckdb-0.1.1.tar.gz",
    "platform": null,
    "description": "# ifc2duckdb\n\nConvert IFC files to DuckDB format for fast analysis and querying of Building Information Modeling (BIM) data.\n\n[![Python Version](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/downloads/)\n[![License](https://img.shields.io/badge/license-LGPL--3.0--or--later-green.svg)](https://spdx.org/licenses/LGPL-3.0-or-later.html)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n![](./docs/ifc2duckdb.png)\n\n## Features\n\n- **Fast Conversion**: Convert IFC files to DuckDB format for high-performance querying\n- **Full Schema Support**: Create complete IFC schema tables or only those present in the file\n- **Geometry Support**: Extract and store 3D geometry data with materials\n- **Property Sets**: Include IFC property set data\n- **Inverse Relationships**: Store entity relationships for complex queries\n- **Command Line Interface**: Easy-to-use CLI for batch processing\n- **Python API**: Programmatic access for integration into larger workflows\n\n## Installation\n\n### From PyPI (recommended)\n\n```bash\npip install ifc2duckdb\n```\n\n### From source\n\n```bash\ngit clone https://github.com/chuongmep/ifc-2-duckdb.git\ncd ifc-2-duckdb\npip install -e .\n```\n\n### Development installation\n\n```bash\ngit clone https://github.com/chuongmep/ifc-2-duckdb.git\ncd ifc-2-duckdb\npip install -e \".[dev]\"\n```\n\n## Requirements\n\n- Python 3.10+\n- ifcopenshell >= 1.0.0\n- duckdb >= 0.7.0\n- numpy >= 1.20.0\n- ifcpatch >= 0.1.0\n\n## Quick Start\n\n### Command Line Usage\n\n```bash\n# Basic conversion\nifc2duckdb input.ifc output.duckdb\n\n# With options\nifc2duckdb input.ifc --database output.duckdb --no-geometry --verbose\n\n# Help\nifc2duckdb --help\n```\n\n### Python API Usage\n\n```python\nimport ifc2duckdb\nimport ifcopenshell\n\n# Open IFC file\nifc_file = ifcopenshell.open(\"racbasicsampleproject.ifc\")\n\n# Create patcher with default settings\npatcher = ifc2duckdb.Patcher(\n    ifc_file,\n    database=\"output.duckdb\"\n)\n\n# Convert to DuckDB\npatcher.patch()\n\n# Get output path\noutput_path = patcher.get_output()\nprint(f\"Database created at: {output_path}\")\n```\n\n### Advanced Usage\n\n```python\nimport ifc2duckdb\nimport ifcopenshell\n\n# Open IFC file\nifc_file = ifcopenshell.open(\"racbasicsampleproject.ifc\")\n\n# Create patcher with custom settings\npatcher = ifc2duckdb.Patcher(\n    ifc_file,\n    database=\"output.duckdb\",\n    full_schema=False,           # Only create tables for classes in the file\n    is_strict=True,              # Strict data type validation\n    should_expand=True,          # Expand entity lists into separate rows\n    should_get_inverses=True,    # Include inverse relationships\n    should_get_psets=True,       # Include property set data\n    should_get_geometry=True,    # Include geometry data\n    should_skip_geometry_data=False  # Include geometry for representation tables\n)\n\n# Convert to DuckDB\npatcher.patch()\n```\n\n## Database Schema\n\nThe converted DuckDB database contains several types of tables:\n\n### Core Tables\n- **`id_map`**: Maps IFC entity IDs to their class names\n- **`metadata`**: Contains IFC file metadata (schema, preprocessor info)\n\n### IFC Entity Tables\n- One table per IFC class (e.g., `IfcWall`, `IfcDoor`, `IfcWindow`)\n- Each table contains all attributes of the IFC entity\n- Primary key is `ifc_id` (the IFC entity ID)\n\n### Geometry Tables\n- **`shape`**: Contains placement and transformation data\n- **`geometry`**: Contains mesh data (vertices, edges, faces, materials)\n\n### Property Set Tables\n- **`psets`**: Contains property set data in key-value format\n\n## Querying Examples\n\n```sql\n-- Find all walls\nSELECT * FROM \"IfcWall\";\n\n-- Find walls with specific properties\nSELECT w.*, p.name, p.value \nFROM \"IfcWall\" w\nJOIN psets p ON w.ifc_id = p.ifc_id\nWHERE p.pset_name = 'Pset_WallCommon';\n\n-- Get geometry for all elements\nSELECT s.*, g.verts, g.faces\nFROM shape s\nJOIN geometry g ON s.geometry = g.id;\n\n-- Find elements by material\nSELECT s.ifc_id, g.materials\nFROM shape s\nJOIN geometry g ON s.geometry = g.id\nWHERE g.materials LIKE '%concrete%';\n```\n\n## Development\n\n### Running Tests\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=ifc2duckdb --cov-report=html\n\n# Run specific test file\npytest tests/test_patcher.py\n```\n\n### Code Formatting\n\n```bash\n# Format code\nblack ifc2duckdb tests\nisort ifc2duckdb tests\n\n# Check formatting\nblack --check ifc2duckdb tests\nisort --check-only ifc2duckdb tests\n```\n\n### Type Checking\n\n```bash\nmypy ifc2duckdb --ignore-missing-imports\n```\n\n### Linting\n\n```bash\nflake8 ifc2duckdb tests\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Make your changes\n4. Run tests and linting (`make test lint`)\n5. Commit your changes (`git commit -m 'Add amazing feature'`)\n6. Push to the branch (`git push origin feature/amazing-feature`)\n7. Open a Pull Request\n\n## License\n\nThis project is licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later) - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Based on the [Ifc2Sql](https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcpatch/ifcpatch/recipes/Ifc2Sql.py) recipe from IfcOpenShell\n- Inspired by the [XbimEssentials](https://github.com/xBimTeam/XbimEssentials) project\n- Built on top of [IfcOpenShell](https://ifcopenshell.org/) and [DuckDB](https://duckdb.org/)\n\n## References\n\n- [IfcOpenShell Documentation](https://docs.ifcopenshell.org/)\n- [IfcPatch Documentation](https://docs.ifcopenshell.org/ifcpatch.html)\n- [DuckDB Documentation](https://duckdb.org/docs/)\n- [OSArch Community Discussion](https://community.osarch.org/discussion/1535/ifc-stored-as-sqlite-and-mysql)\n- [DuckDB Cloud Storage](https://duckdb.org/docs/stable/guides/network_cloud_storage/duckdb_over_https_or_s3.html)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Convert IFC files to DuckDB format for fast analysis and querying",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/chuongmep/ifc-2-duckdb/issues",
        "Documentation": "https://github.com/chuongmep/ifc-2-duckdb#readme",
        "Homepage": "https://github.com/chuongmep/ifc-2-duckdb",
        "Repository": "https://github.com/chuongmep/ifc-2-duckdb"
    },
    "split_keywords": [
        "ifc",
        " duckdb",
        " building-information-modeling",
        " bim",
        " database",
        " conversion"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d697913248bb64b01e03bae70ca7f124d1aac4a0472514c12d23a9e3c90565b1",
                "md5": "dc7e6ba53c58b861613a2a4634103008",
                "sha256": "6e9440719c111cb0c17458e2447e75be7b73598c0d6e83c57a8a91ccc6aaf82f"
            },
            "downloads": -1,
            "filename": "ifc2duckdb-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dc7e6ba53c58b861613a2a4634103008",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 12420,
            "upload_time": "2025-09-14T15:40:11",
            "upload_time_iso_8601": "2025-09-14T15:40:11.295268Z",
            "url": "https://files.pythonhosted.org/packages/d6/97/913248bb64b01e03bae70ca7f124d1aac4a0472514c12d23a9e3c90565b1/ifc2duckdb-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7500e17448be7e24cf07276a225e8bad6b5c682b16a0ca909a5ac4edc7336639",
                "md5": "8753f8a149151b2ded96eb21accc58c7",
                "sha256": "220e247ff2223d564941c83cb905c1b6fdb49b71274390c32bf75a655a280424"
            },
            "downloads": -1,
            "filename": "ifc2duckdb-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8753f8a149151b2ded96eb21accc58c7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 844477,
            "upload_time": "2025-09-14T15:40:12",
            "upload_time_iso_8601": "2025-09-14T15:40:12.579236Z",
            "url": "https://files.pythonhosted.org/packages/75/00/e17448be7e24cf07276a225e8bad6b5c682b16a0ca909a5ac4edc7336639/ifc2duckdb-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-14 15:40:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "chuongmep",
    "github_project": "ifc-2-duckdb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "ifcopenshell",
            "specs": [
                [
                    ">=",
                    "0.8.0"
                ]
            ]
        },
        {
            "name": "duckdb",
            "specs": [
                [
                    ">=",
                    "0.7.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.20.0"
                ]
            ]
        },
        {
            "name": "ifcpatch",
            "specs": [
                [
                    ">=",
                    "0.1.0"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "ifc2duckdb"
}
        
Elapsed time: 2.13930s