Skip to main content

Native ifc-lite geometry-data export for Python (welded, IFC Z-up, world coords).

Project description

ifclite-geom

Native ifc-lite geometry tessellation for Python. It turns an IFC file into per-entity triangle meshes with no Node, no WASM, and no subprocess: the Rust geometry kernel runs directly inside the Python process.

Meshes come back welded, IFC Z-up, in absolute world metres, keyed by IFC STEP id (occurrences only). This is the analysis-ready export, distinct from the render-oriented GLB the viewer uses.

Install

pip install ifclite-geom

Prebuilt wheels ship for CPython 3.9+ on Linux (x86_64, aarch64), macOS (Apple silicon and Intel), and Windows (x64). No Rust toolchain needed.

Quick start

The module is ifclite_geom and exposes two functions. Both take the raw IFC file as bytes and return the same geometry; they differ only in the output format.

import ifclite_geom
import numpy as np

with open("model.ifc", "rb") as f:
    ifc_bytes = f.read()

data = ifclite_geom.geometry_data_buffers(ifc_bytes)

print(data["element_count"], "elements")
print("up axis:", data["up_axis"], "| units:", data["units"])
print("rtc offset:", data["rtc_offset"])

for step_id, el in data["elements"].items():
    verts = np.frombuffer(el["vertices"], dtype=np.float64).reshape(-1, 3)
    faces = np.frombuffer(el["faces"],    dtype=np.uint32 ).reshape(-1, 3)
    print(step_id, el["ifc_type"], el["global_id"], verts.shape, faces.shape)

Prefer no numpy dependency? Use the JSON variant, which returns the same data as arrays of numbers:

import ifclite_geom, json

doc = json.loads(ifclite_geom.geometry_data_json(ifc_bytes))
first = next(iter(doc["elements"].values()))
print(first["ifc_type"], first["vertices"][0])  # [x, y, z] in metres

API

geometry_data_buffers(ifc_bytes: bytes) -> dict

The fast path. Vertices and faces come back as raw little-endian byte buffers so you can hand them straight to numpy.frombuffer with zero parsing.

{
  "up_axis": "Z",            # always Z (IFC native)
  "units": "m",              # always metres
  "rtc_offset": [x, y, z],   # geo-reference offset already folded into vertices
  "element_count": 1234,
  "elements": {
    <step_id:int>: {
      "ifc_type":  "IfcWall",
      "global_id": "3vB2...",   # may be None
      "name":      "Basic Wall:...",  # may be None
      "color":     [r, g, b, a],      # 0..1
      "vertices":  <bytes>,           # f64 little-endian, xyz triplets
      "faces":     <bytes>,           # u32 little-endian, triangle indices
    },
    ...
  }
}

Decode the buffers with:

verts = np.frombuffer(el["vertices"], dtype=np.float64).reshape(-1, 3)  # (V, 3)
faces = np.frombuffer(el["faces"],    dtype=np.uint32 ).reshape(-1, 3)  # (F, 3)

geometry_data_json(ifc_bytes: bytes) -> str

The same geometry as a readable ifc-lite-geometry-data JSON document (a string; call json.loads on it). Vertices are [x, y, z] arrays and faces are [a, b, c] index arrays, so no numpy is required. Each element also carries global_id and name when the source entity has them.

Notes

  • One mesh per element. Per-material submeshes of an element are merged into a single indexed triangle soup, keyed by its IFC STEP id.
  • Coordinates are absolute world metres. The per-element local frame and the model RTC offset are folded back into every vertex. For geo-referenced models rtc_offset is non-zero; subtract it if you want f32-friendly local coordinates.
  • Welded and indexed. Coincident corners are merged (1 micron grid), so closed-mesh consumers (volume, watertightness checks) work directly.
  • Occurrences only. Type-product / RepresentationMap geometry is not emitted, matching what occurrence-based tessellators produce.
  • Errors surface as RuntimeError (geometry pipeline failure) or ValueError (JSON serialization failure).

Examples

Runnable scripts live in examples/:

License

MPL-2.0. Part of the ifc-lite project.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

ifclite_geom-4.2.0-cp39-abi3-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

ifclite_geom-4.2.0-cp39-abi3-macosx_11_0_arm64.whl (1.8 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

ifclite_geom-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl (1.9 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file ifclite_geom-4.2.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: ifclite_geom-4.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ifclite_geom-4.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a76e2f6234978148ec606006f2d9b52e30f9f4ef1c1c99554377d4691f148347
MD5 55dc2231f8b90d42993294cfdd074bdd
BLAKE2b-256 4279a2b7dd87a3ce1742e09ec988bf7c21da349dfbe9fb9d25c52c0c40834f66

See more details on using hashes here.

Provenance

The following attestation bundles were made for ifclite_geom-4.2.0-cp39-abi3-win_amd64.whl:

Publisher: python-wheels.yml on LTplus-AG/ifc-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9515a7e11be349ba91164babbc49486db47bdde1388b1c716c4bf59353dc2f9b
MD5 e6d84898a6b13c104725d4bd76baa7f6
BLAKE2b-256 9faef5470a42bf6ff5bc15183624c4997b39f3898019c174a9f19d292ada97de

See more details on using hashes here.

Provenance

The following attestation bundles were made for ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-wheels.yml on LTplus-AG/ifc-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1ca2630dd5d3fd4795761763952b3f7080f4417bb989b5346715c5302fc7a928
MD5 f8f1f6a9a5a75bb071c50f987743fbdc
BLAKE2b-256 671291e1fd893c1bf9ddc0e6c144bfa11469cf0a196583eb81d03e819502afda

See more details on using hashes here.

Provenance

The following attestation bundles were made for ifclite_geom-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: python-wheels.yml on LTplus-AG/ifc-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ifclite_geom-4.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ifclite_geom-4.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9dec8411ebe35a5a28731b686b89db50277aa3b722bdfad04f31e228e6904aa1
MD5 c5eedadf76313366e58eb3d6c3979fbb
BLAKE2b-256 b7e9c45e4c0ab889c7aa8458fbb973d4dc206464941ee85cc1f26b46a6889fc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for ifclite_geom-4.2.0-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: python-wheels.yml on LTplus-AG/ifc-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ifclite_geom-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ifclite_geom-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 946c008ae7b0b222ebb2ab67f989e821c805f07dc1c7618fac2f6b185fb4e525
MD5 bbe0b6ae871dfc96425b92344d570acd
BLAKE2b-256 2dba12298d19ec904e75fefa740e858e918df051e666962d5804cd0467b72033

See more details on using hashes here.

Provenance

The following attestation bundles were made for ifclite_geom-4.2.0-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: python-wheels.yml on LTplus-AG/ifc-lite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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