Quickstart: write Python CAD
Install Foundation and build a part in a few lines of Python. If you don’t want to install anything yet, try the same code in the Playground.
Steps
-
Install Foundation (Python 3.10+):
pip install cadbuildr-foundationMore options are on the install page.
-
Write a part. Save this as
cube.py:from cadbuildr.foundation import Part, Sketch, Point, Square, Extrusion, show class Cube(Part): def __init__(self, size: float = 10): super().__init__() sketch = Sketch(self.xy()) square = Square.from_center_and_side(Point(sketch, 0, 0), size) self.add_operation(Extrusion(square, size)) show(Cube()) -
View it.
show()sends the part to a viewer. The easiest way is to paste the file into the Playground, or open the folder in the Prototype app and run it there. Runningpython cube.pyfrom a terminal needs the local viewer bridge (pip install cadbuildr-broker, then runcadbuildr-broker). Without it,show()prints “Could not connect to broker”.
Next
- Your first part: the same cube, explained step by step
- Cheatsheet: the whole API on one page
- Examples