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.
  • 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.25

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

Total release size: 7.6 MB

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

Download URL cad_core-0.1.25-cp312-cp312-win_amd64.whl
Size 869.4 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
f11450a5e83856c96f2c24ce0e5061ea2a53a4500ea7d3c335a3d3251c3a9866
BLAKE2b-256 checksum
How to use checksums
a911279095f3eec78f972c03793978e1ac43293589949eecbccc40325ee84c8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

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

Download URL cad_core-0.1.25-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 6.7 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
217ad0ce399e0e7ff89608b105e83ba088eda20a48f850a38f5b01a56ac70852
BLAKE2b-256 checksum
How to use checksums
d8316839ec030d4c82f63ad2feba1d65e5a7e33dc6ced9c15ac5d2f68622293d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 20, 2026.

Transparency log

Security for cad-core 0.1.25

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.25-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 Oct 20, 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