# Getting started

pycodecad needs a graphics card with OpenGL 3.3; see [Limitations](https://offerrall.github.io/doc/pycodecad/limitations.md) for the
platforms. Once installed, check that the command works:

```bash
pycodecad --version
```

## A first part

Open a window on a file. If the file does not exist, pycodecad creates it from a small example:

```bash
pycodecad part.py
```

A part can also be several files in one folder (`gear.py` imports `teeth.py`): open the folder
with `pycodecad gear/` and switch between its files in the window. See
[The window](https://offerrall.github.io/doc/pycodecad/window.md#a-part-in-several-files).

A part is a plain Python script that builds shapes with build123d and passes them to `show()`:

```python
from build123d import Axis, Box, Cylinder, fillet
from pycodecad import show

plate = Box(40, 30, 8) - Cylinder(5, 8)
plate = fillet(plate.edges().filter_by(Axis.Z), radius=3)
show(plate, name="plate", color="#F4B02A")
```

Units are millimetres and Z points up. Only what you pass to `show()` is in the scene: see
[Scripts](https://offerrall.github.io/doc/pycodecad/scripts.md).

## Run and save

The script runs once when the window opens. After that, nothing happens by itself:

1. Edit the code.
2. Press **Run** (Ctrl+R or F5) to see the result.
3. Press **Save** (Ctrl+S) when you like it.

If the script fails, the window shows the error with its line, and the last good part stays on
screen. More in [The window](https://offerrall.github.io/doc/pycodecad/window.md).

## Export

In the window, **Export** writes the part next to the script (`part.stl`, `part.3mf`...). From a
terminal:

```bash
pycodecad export part.py part.stl
pycodecad export part.py part.3mf --profile bambu    # 3MF for Bambu Studio, with names and colors
```

Formats: STL, 3MF, STEP, GLB and BREP. See [Command line](https://offerrall.github.io/doc/pycodecad/cli.md).

## Without pycodecad

`python part.py` also runs the script: `show()`, `clear()` and `frame()` then do nothing and `expose()` uses
the defaults. See [Scripts](https://offerrall.github.io/doc/pycodecad/scripts.md#plain-python).

## Next

- Try the [examples](https://github.com/offerrall/pycodecad/tree/main/examples): `pycodecad examples` copies them to `./pycodecad-examples` (once)
  and opens the folder: loose parts in `parts.py`, composed in `gearbox.py` and shown in `assembly.py`, turning in
  `gears_turning.py`.
- Make a part to measure with [Parameters](https://offerrall.github.io/doc/pycodecad/parameters.md).
- Let an assistant work on it: [Working with an AI assistant](https://offerrall.github.io/doc/pycodecad/ai.md).
