CAD as Code

Parametric Modeling and Engineering with Python

Cover of CAD as Code

A textbook on building CAD models as Python programs. It covers modeling techniques, the geometric and topological foundations underneath them, and the workflow around a model: version control, tests, assemblies, data exchange, meshing, finite element simulation and parameter optimization. Twelve chapters with exercises, 121 pages; it assumes basic Python and no prior CAD experience. It grew out of my course on programming CAx systems and serves as companion reading for it.

Get the book

The book is published open access by HM Munich University of Applied Sciences through the HM library.

The text and figures are licensed under CC BY 4.0, the code examples under the MIT License, so you can use them freely in your own work. If you find an error or have a suggestion, please open an issue.

Citation

David M. Straub, CAD as Code: Parametric Modeling and Engineering with Python. HM Munich University of Applied Sciences, 2026. DOI: 10.60948/OPUS-1358

Contents

Part I – Parts from Code

  1. The Case for CAD as Code
  2. First Parts
  3. Profiles into Solids
  4. Designing with Parameters

Part II – Under the Hood

  1. Anatomy of a Solid
  2. The Mathematics of Shape
  3. Freeform Modeling

Part III – Engineering as Software

  1. Models You Can Trust
  2. Assemblies and Release Pipelines
  3. From Solids to Meshes
  4. Simulation
  5. Searching the Design Space