gumyr / build123d
git clone https://github.com/gumyr/build123d.git
v0.13.0 · 1mo ago
A python CAD programming library
+10
stars, 24h · #3,431
+~68
stars, 7 days · #3,060
+~290
stars, 30 days · #2,789
3.5k
★ total · +2% this week
311
forks · 283 open issues
Star history (as recorded here)
LanguagePython
LicenseApache-2.0
Created2022-07-05 (4y ago)
Last push2d ago
Watchers39
OwnerUser
GitHub topics
Links
- GitHub: github.com/gumyr/build123d
- Releases · Issues · Hacker News mentions
README excerpt
Documentation | Cheat Sheet | Discord | Discussions | Issues | Contributing build123d is a Python-based, parametric [boundary representation (BREP)][BREP] modeling framework for 2D and 3D CAD. Built on the [Open Cascade] geometric kernel, it provides a clean, fully Pythonic interface for creating precise models suitable for 3D printing, CNC machining, laser cutting, and other manufacturing processes. ## Features Designed for modern, maintainable CAD-as-code, build123d combines clear architecture with expressive, algebraic modeling. It offers: - Minimal or no internal state depending on mode, - Explicit 1D, 2D, and 3D geometry classes with well-defined operations, - Extensibility through subclassing and functional composition—no monkey patching, - Standards-compliant code (PEP 8, mypy, pylint) with rich pylance type hints, - Deep Python integration—selectors as lists, locations as iterables, and natural conversions (`Solid(shell)`, `tuple(Vector)`), - Operator-driven modeling (`obj += sub_obj`, `Plane.XZ * Pos(X=5) * Rectangle(1, 1)`) for algebraic, readable, and composable design logic, - Export formats to popular CAD tools such as [FreeCAD] and SolidWorks. ## Usage Although wildcard imports are generally bad practice, build123d scripts are usually self contained and importing the large number of objects and methods into the namespace is common: [code] ### Constructing a 1D Shape Edges, Wires (multiple connected Edges), and Curves (a Compound of Edges and Wires) are the 1D Shapes available in build123d. A single Edge can be created from a Line object with two vector-like positions: [code] Additional Edges and Wires may be added to (or subtracted from) the initial line. These objects can reference coordinates along another line through the position (`@`) and tangent (`%`) operators to specify input Vectors: [code] ### Upgrading to 2D and 3D Faces, Shells (multiple connected Faces), and Sketches (a Compound of Faces and Shells) are the 2D Shapes available in build123d. The previous line is sufficiently defined to close the Wire and create a Face with `make_hull`: [code] A Circle face is translated with `Pos`, a Location object like `Rot` for transforming Shapes, and subtracted from the sketch. This sketch face is then extruded into a Solid part: [code] ### Adding to and modifying part Solids and Parts (a Compound of Solids) are the 3D Shapes available in build123d. A second part can be created from an additional Face. Planes can also be used for positioning and orienting Shape objects. Many objects offer an affordance for alignment relative to the object origin: [code] Shape topology can be extracted from Shapes with selectors which return ShapeLists. ShapeLists offer methods for sorting, grouping, and filtering Shapes by Shape properties, such as finding a Face by area and selecting position along an Axis and specifying a target with a list slice. A Plane is created from the specified Face to locate an iterable of Locations to place mu