Parametric Modeling and Engineering with Python by David M. Straub
A book about building real engineering geometry in code: boundary representations, the mathematics of curves and surfaces, freeform modeling, models you can test and release, meshing, simulation, and searching a design space. It uses CadQuery and the OpenCascade kernel throughout.
Published by HM Munich University of Applied Sciences.
DOI 10.60948/OPUS-1358 ·
URN urn:nbn:de:bvb:m347-opus-13585
Part I: Parts from Code
- The Case for CAD as Code
- First Parts
- Profiles into Solids
- Designing with Parameters
Part II: Under the Hood
- Anatomy of a Solid
- The Mathematics of Shape
- Freeform Modeling
Part III: Engineering as Software
- Models You Can Trust
- Assemblies and Release Pipelines
- From Solids to Meshes
- Simulation
- Searching the Design Space
| Path | Contents |
|---|---|
chapters/ |
The book text, as MyST Markdown |
figures/*.py |
Scripts that generate every figure |
figures/generated/ |
Their committed output (so the book builds without running them) |
figures/static/ |
Hand-drawn and hand-edited figures |
template/ |
The Typst book template (jtex) |
myst.yml |
Project and export configuration |
The PDF build needs only MyST and Typst, because the generated figures are committed.
npm install -g mystmd # myst v1.10+
# install typst 0.15+ (https://github.com/typst/typst), then:
make build # -> main.pdfTypst 0.15 or newer is required (the template uses variable fonts).
Other targets:
make watch # live preview
make pdfa # PDF/A-2b output, for archiving
make clean # remove _build/Only needed if you change a figure script. This pulls in the full CAD and
simulation stack, which is pinned in pyproject.toml and locked in uv.lock:
uv sync --group figures
uv run make figuresFigures are rendered off-screen with PyVista/VTK. Output depends on the GPU and driver, so the same script on another machine gives a visually identical file with different bytes, even at identical package versions. Review a figure change by opening the image.
This repository is dual-licensed:
- The book – all prose in
chapters/and all figures infigures/generated/andfigures/static/– is licensed under Creative Commons Attribution 4.0 International (seeLICENSE). - The code – all code examples in the text, the figure scripts in
figures/, and the Typst template intemplate/– is licensed under the MIT License (seeLICENSE-CODE), so you can lift anything from the book into your own work without attribution obligations.
See CITATION.cff, or use the "Cite this repository" button on
GitHub.
If you find an error, please open an issue. See
CONTRIBUTING.md.
