cad3d-ir
cad3d-ir is a typed, kernel-neutral intermediate representation for 3D CAD
product data.
The core package represents source documents, reusable product definitions, configurations, component occurrences, bodies, geometry-resource references, materials, appearances, provenance, and namespaced source extensions. Exact B-Rep and mesh bytes remain external resources rather than Python or JSON objects embedded in the manifest.
The core intentionally does not depend on Open CASCADE, CadQuery, a vendor SDK, or a viewer. Format parsers and geometry backends integrate through separate adapter packages.
Status
The 0.2.0 core provides:
- typed Pydantic models and a generated JSON Schema (IR
0.2.0); - graph validation for IDs and cross-object references;
- deterministic manifest JSON serialization;
- atomic, content-addressed directory resource writing;
- optional resource size and SHA-256 validation;
- structured importer diagnostics and a format-adapter protocol;
- package-level
visualizations: derived, display-only glTF binary assets that pack every placed body so a viewer needs no product-graph logic; cad3d_ir.mesh: a dependency-free glTF binary (GLB) writer, validator and triangle helpers shared by adapters;- a built-in
MeshImporterfor STL (ASCII/binary) and Wavefront OBJ; cad3d-ir validate,cad3d-ir schemaandcad3d-ir importCLIs.
Kernel-backed importers stay separate. This repository's cad3d-ir-step
workspace member reads STEP (AP203/AP214/AP242) and IGES through Open CASCADE
XDE and can emit the same visualization meshes.
Visualization meshes
Adapters write display geometry on request:
from pathlib import Path
from cad3d_ir import DirectoryResourceWriter
from cad3d_ir.importers import ImportOptions, MeshImporter
result = MeshImporter().import_file(
Path("part.stl"),
options=ImportOptions(),
resources=DirectoryResourceWriter("converted"),
)
preview = result.package.visualizations[0] # kind="glb", scope="package"
print(preview.statistics["triangles"], preview.resource_id)
The GLB is self-contained: positions, optional normals and uint32 indices in
one buffer. Node 0 carries the single conversion from package units and Z-up
to glTF metres and Y-up (extras.cad3d_ir.length_unit_to_m), so every other
node and mesh stays in package coordinates. Each node's extras.id is the IR
occurrence (or root product) id, each mesh's extras.id the body id, and
face/edge primitives list [pick_id, first_index, index_count] ranges in
extras.ranges, so viewers can map a picked triangle back to a face.
Development
uv sync --dev
uv run pytest
uv run ruff check .
uv run python scripts/sync_schema.py --check
# STEP adapter
uv run --package cad3d-ir-step pytest packages/cad3d-ir-step/tests
uv run --package cad3d-ir-step cad3d-ir-step model.step output/
Minimal use
from cad3d_ir import (
CadPackage,
CoordinateSystem,
UnitSystem,
dump_manifest,
load_manifest,
)
package = CadPackage(
format="cad3d-ir",
version="0.1.0",
id="package-example",
units=UnitSystem(length_unit="mm"),
coordinate_system=CoordinateSystem(),
)
dump_manifest(package, "manifest.json", pretty=True)
loaded = load_manifest("manifest.json")
assert loaded == package
See the design document for the package boundary, model invariants, geometry-resource strategy, and staged scope. The reference adapter and abstraction gate are described in the adapter design note.
License
MIT
Metadata
Release files for cad3d-ir 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cad3d_ir-0.2.0.tar.gz | 107.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cad3d_ir-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 151.7 kB
Release files / cad3d_ir-0.2.0.tar.gz
| Download URL | cad3d_ir-0.2.0.tar.gz |
|---|---|
| Size | 107.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d02be02cb8188010091cb84483aca2f43937ea0b8f0184cd1cc576143267722
|
|
BLAKE2b-256 checksum How to use checksums |
140db9a4a5a4a38f3bb52441822a03b46b8bee5b5ba4acedf160d37ecaf8fa7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / cad3d_ir-0.2.0-py3-none-any.whl
| Download URL | cad3d_ir-0.2.0-py3-none-any.whl |
|---|---|
| Size | 44.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a05eb148b5748a9a6dec52d480819ddded93b8a89ab04e1ad14449bd7eb57cb
|
|
BLAKE2b-256 checksum How to use checksums |
6737852b3ab0475cbfbb9177451ef00caaba3e051442b243db45aa80b070f8eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for cad3d-ir 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.