QuickstartsWrite Python CAD

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

  1. Install Foundation (Python 3.10+):

    pip install cadbuildr-foundation

    More options are on the install page.

  2. 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())
  3. 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. Running python cube.py from a terminal needs the local viewer bridge (pip install cadbuildr-broker, then run cadbuildr-broker). Without it, show() prints “Could not connect to broker”.

Next