Skip to main content

cad-core

A pure-Python, headless CAD kernel built on top of OpenCASCADE (via OCP). It provides parametric shape creation, boolean operations, sketching, modifier stacks (fillet, array, extrude, ...), undo/redo, and project (de)serialization — with no GUI framework dependency.

cad-core is meant to be embedded in a UI layer (desktop, web, etc.) that supplies its own rendering and input handling; this package owns the geometry model and business logic only.

Features

  • Parametric shapes — box, sphere, cylinder, cone, torus, rectangle, circle, polyline, imported (STEP/IGES) geometry.
  • Boolean operations — union, subtraction and intersection, with inputs kept as editable internal components.
  • Modifier stack — fillet, corner round, polyline round, rectangular array (1D/2D/3D), extrude, sweep (a profile along a polyline path) — each wraps a source shape and recomputes automatically when the source or its parameters change.
  • Sketching — 2D lines, arcs, rectangles, circles, and polylines scoped to a reference plane (standard or arbitrary), with grid/snap helpers.
  • Reference planes — standard (XY/XZ/YZ), arbitrary (translation + rotation), or derived from a picked face.
  • Undo/redo — snapshot-based command stack shared by both the 3D geometry manager and the 2D sketch manager.
  • Geometry revisions — ManagedShape.geometry_revision changes whenever a shape's geometry is replaced and stays the same for cosmetic edits (rename, colour) and for an update_shape call whose properties equal the current ones (that call is a no-op: no rebuild, notification or undo step). Undo/redo restores it, so a UI or analysis layer can tell when it needs to re-mesh or recompute.
  • Project persistence — save/load full project state to a .cadw ZIP archive (parametric properties + embedded STEP for non-parametric geometry).
  • Headless by design — the core managers and services have no UI framework dependency and run in any Python 3.12 environment; only optional view/selection services depend on an OCP AIS viewer context.

See ARCHITECTURE.md for a detailed description of the module layout and design.

Requirements

Installation

This project uses uv for dependency management.

uv sync

To include the dev toolchain (tests, linting, type checking):

uv sync --group dev

Usage

from cad_core.managers.geometry_manager import CoreGeometryManager
from cad_core.enums import ShapeType
from cad_core.models.shape_properties import BoxProperties, SphereProperties

manager = CoreGeometryManager()

box = manager.create_shape(ShapeType.BOX, BoxProperties(width=50, height=30, depth=20))
sphere = manager.create_shape(ShapeType.SPHERE, SphereProperties(radius=20))
print(box.shape_id, box.name)

# Boolean union of two top-level shapes
union_id = manager.union_shapes([box.shape_id, sphere.shape_id])

manager.undo()
manager.redo()

Sketching on a reference plane:

from cad_core.managers.sketch_manager import CoreSketchManager
from cad_core.enums import StandardPlane

plane = manager.create_plane_from_standard(StandardPlane.XY)
sketch = CoreSketchManager(plane_id=plane.shape_id, plane_props=plane.properties)
rect = sketch.create_rectangle(u=0, v=0, width=40, height=20)

Saving and loading a project:

from cad_core.services.project_service import ProjectSerializer

ProjectSerializer.save_project("my_part.cadw", manager)

Development

Common tasks are wired up via invoke (see tasks.py):

uv run invoke lint         # ruff check
uv run invoke format       # ruff format
uv run invoke typecheck    # ty check
uv run invoke test         # pytest
uv run invoke test-cov     # pytest with coverage
uv run invoke check        # lint + typecheck + test

Or invoke the underlying tools directly:

uv run pytest
uv run ruff check src tests
uv run ty check src tests

Building a release wheel

A Cython-compiled release build (no .py sources, .pyi stubs only) can be produced with:

uv sync --group release
uv run invoke build-release

Project layout

src/cad_core/
├── enums.py           # ShapeType, ShapeCategory, view/selection/tool enums
├── models/            # Shape property dataclasses (BoxProperties, FilletProperties, ...)
├── services/          # Stateless/OCP-facing operations (geometry, sketch, selection, view, undo/redo, project I/O)
└── managers/          # Stateful orchestration (CoreGeometryManager, CoreSketchManager)

License

Proprietary — see LICENSE. Third-party notices are listed in NOTICE.

Metadata

Release files for cad-core 0.1.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for cad-core 0.1.28
File Interpreter ABI Platform Actions
cad_core-0.1.28-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for cad_core-0.1.28-cp312-cp312-win_amd64.whl
cad_core-0.1.28-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for cad_core-0.1.28-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 8.2 MB

Release files / cad_core-0.1.28-cp312-cp312-win_amd64.whl

Download URL cad_core-0.1.28-cp312-cp312-win_amd64.whl
Size 889.7 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6e3dda2f122f87838a771afe7b715b4019a3c3c252922c303277b10d0ad4de38
BLAKE2b-256 checksum
How to use checksums
f031d65b9303a39f0e3ed0a212453a38c02c944e25619642a7f3d3dbf4562d86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Release files / cad_core-0.1.28-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL cad_core-0.1.28-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 7.3 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9c1fb94d18ba20b018b9f0ede4a1f2e2ca4c00d0749dd646254ebd79abfa9bac
BLAKE2b-256 checksum
How to use checksums
79a380a3f77e29626b09d8c1707aab36bdfe17f54e70dea8ab965b7656620f4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

Security for cad-core 0.1.28

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cad_core-0.1.28-cp312-cp312-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page