build123d
raw JSON → 0.10.0 verified Sat May 09 auth: no python
A Python CAD programming library for creating parametric 3D models using a scripting approach. Current version is 0.10.0, requiring Python >=3.10 and <3.14. It provides both algebra and builder modes for constructing solids, and is built on top of cadquery-ocp (OpenCascade Python bindings). Release cadence is irregular, with major versions around every few months.
pip install build123d Common errors
error AttributeError: 'NoneType' object has no attribute 'location' ↓
cause The operation did not produce a shape (e.g., subtraction removed everything, or a cut was misaligned).
fix
Check your geometry operations – ensure the objects actually intersect or that you're not cutting the entire part away.
error ImportError: cannot import name 'show_object' from 'build123d' ↓
cause Older version of build123d or missing ocp_vscode for Jupyter viewing.
fix
Upgrade:
pip install -U build123d; for viewing, install ocp_vscode: pip install ocp_vscode and use from build123d import show_object. error OSError: [WinError 126] The specified module could not be found when importing build123d ↓
cause Missing C++ redistributables on Windows (OpenCascade DLLs not found).
fix
Install Microsoft Visual C++ Redistributable for Visual Studio 2015-2022 (x64).
error RuntimeError: Builder mode only allows one pending shape at a time ↓
cause Nested BuildPart or BuildSketch without proper context management.
fix
Ensure you're not nesting builder contexts incorrectly – use separate
with blocks or close the inner context before starting another. Warnings
breaking In v0.10.0, methods `is_null`, `is_valid`, `shape_type` were changed to properties – remove parentheses from calls like `shape.is_valid()` -> `shape.is_valid`. ↓
fix Change `shape.is_valid()` to `shape.is_valid`, `shape.is_null()` to `shape.is_null`, `shape.shape_type()` to `shape.shape_type`.
deprecated In v0.9.0, several previously deprecated items were removed, including old-style `S` prefix aliases (e.g., `Solid` instead of `S`). Check release notes for full list. ↓
fix Use current names: `Solid` instead of `S`, `Face` instead of `F`, etc.
gotcha VTK version conflict when upgrading from build123d <=0.8.0 to 0.9.0 or later – old VTK from cadquery-ocp can cause import errors. ↓
fix Either create a fresh virtual environment, or uninstall VTK and reinstall a compatible version: `pip uninstall vtk && pip install vtk==9.3.1`.
gotcha `show_object` only works with the ocp_vscode viewer; if not installed, you'll get an ImportError or runtime error. ↓
fix Install `pip install ocp_vscode` or use `export_stl`/`export_step` to save files.
Install
conda install -c conda-forge build123d Imports
- Box
from build123d import Box - Location
from build123d import Location - Cylinder
from build123d import Cylinder - Sphere
from build123d import Sphere - BuildPart
from build123d import BuildPart - export_stl
from build123d import export_stl - show_object
from build123d import show_object
Quickstart
from build123d import *
with BuildPart() as part:
Box(10, 10, 10)
with Locations((0, 0, 5)):
Cylinder(radius=2, height=6, mode=Mode.SUBTRACT)
# Export to STL
export_stl(part.part, "example.stl")
# To view in Jupyter (requires ocp_vscode):
# show_object(part.part)