IfcOpenShell

0.8.5 · active · verified Thu Apr 16

IfcOpenShell is an open-source (LGPL) software library providing an API for working with the Industry Foundation Classes (IFC) data model, used in Building Information Modeling (BIM). The `ifcopenshell` Python library offers high-level bindings and utilities for reading, writing, and manipulating IFC files. It is currently at version 0.8.5 and receives updates aligning with the underlying C++ library, with an irregular release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a new IFC file with a basic 'IfcProject' entity, save it to disk, and then clean up the generated file.

import ifcopenshell
import os

# Create a new IFC4 file
ifc_file = ifcopenshell.template(schema="IFC4")

# Create a project entity
project_guid = ifcopenshell.guid.new()
project = ifc_file.create_entity("IfcProject", project_guid)
project.Name = "My First IfcOpenShell Project"

# Add the project to the file
ifc_file.add(project)

# Define output path
output_path = "my_first_project.ifc"

# Save the IFC file
ifc_file.write(output_path)
print(f"Successfully created IFC file: {output_path}")

# Optional: Clean up the created file for repeated runs
if os.path.exists(output_path):
    os.remove(output_path)
    print(f"Cleaned up {output_path}")

view raw JSON →