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). 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.26

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.26
File Interpreter ABI Platform Actions
cad_core-0.1.26-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for cad_core-0.1.26-cp312-cp312-win_amd64.whl
cad_core-0.1.26-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.26-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Total release size: 7.6 MB

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

Download URL cad_core-0.1.26-cp312-cp312-win_amd64.whl
Size 874.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d3eadc0e2a177dfce56d5ee11789ac5a41b90e8bcdecd847a9acd270f9e46127
BLAKE2b-256 checksum
How to use checksums
96e84536c938b55b6804334e1dde6645638230862f1a3c3a586e43a8e528082b
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 9, 2026.

Transparency log

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

Download URL cad_core-0.1.26-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 6.8 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
b37bb6b2bb7d7c886a4a8e9788359d700895c820e92a10a1b193090cfe46b82a
BLAKE2b-256 checksum
How to use checksums
52e2f9b6e136ce19192174b1d29d6894f703db8f6e15fa015fb731772b1d7668
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 9, 2026.

Transparency log

Security for cad-core 0.1.26

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.26-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 9, 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