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.1 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. The writer takes flat sequences or packed little-endian buffers and can share one vertex set between primitives;- a built-in
MeshImporterfor STL (ASCII/binary) and Wavefront OBJ; cad3d-ir validate,cad3d-ir schemaandcad3d-ir importCLIs.
Kernel-backed and native-format 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. The
cad3d-ir-sldprt member reads SOLIDWORKS parts through
sldkit: it packs the display
meshes SOLIDWORKS saved into the same GLB layout, without reading the B-Rep,
and carries the document metadata and preview image. It is licensed
separately (PolyForm Noncommercial, see its README).
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/
# SOLIDWORKS part adapter
uv run --package cad3d-ir-sldprt pytest packages/cad3d-ir-sldprt/tests
uv run --package cad3d-ir-sldprt cad3d-ir-sldprt part.SLDPRT 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
cad3d-ir and cad3d-ir-step are MIT licensed. packages/cad3d-ir-sldprt
is licensed separately under the PolyForm Noncommercial License 1.0.0 by
UnRobotics Inc., following sldkit; see
its LICENSE for the notice and
commercial contact.
Metadata
Release files for cad3d-ir 0.2.1
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.1.tar.gz | 110.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cad3d_ir-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 157.1 kB
Release files / cad3d_ir-0.2.1.tar.gz
| Download URL | cad3d_ir-0.2.1.tar.gz |
|---|---|
| Size | 110.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
318e4d4dcecc1e0451a9e364151d11ead14753ae578c8c3ce49935e79e919a78
|
|
BLAKE2b-256 checksum How to use checksums |
fef227108b0c579d2ea046a342a358f54a20246bc100d9fcf71af2cf44b1f235
|
| 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.1-py3-none-any.whl
| Download URL | cad3d_ir-0.2.1-py3-none-any.whl |
|---|---|
| Size | 46.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6662426fa2b7350d36c808a813e0a7138733b9b77cc34ccd1fd3cf17a67a5f5d
|
|
BLAKE2b-256 checksum How to use checksums |
e463530dfd5aabfbf3a071b4435d454ee36743580adbb4af446dce6e54310c42
|
| 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.1
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.