Metadata-Version: 2.4
Name: part-grimoire
Version: 0.3.0
Summary: Cast a 3D-printable part from a config file and Python CAD code into STL, STEP, assemblies, exploded views, DXF outlines, Bambu Studio print files, a BOM, and docs.
Author: Spikeon Studio
License-Expression: MIT
Project-URL: Homepage, https://github.com/Spikeon-Studio/part-grimoire
Project-URL: Documentation, https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/index.md
Project-URL: Issues, https://github.com/Spikeon-Studio/part-grimoire/issues
Keywords: cad,3d-printing,step,stl,bom,exploded-view,bambu-studio,badcad
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Manufacturing
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: badcad-occt[occt,svg]<0.3,>=0.2
Requires-Dist: numpy>=2.0
Requires-Dist: pillow>=11
Requires-Dist: moderngl>=5.12
Requires-Dist: matplotlib>=3.9
Requires-Dist: ezdxf>=1.3
Provides-Extra: text
Requires-Dist: badcad-occt[text]<0.3,>=0.2; extra == "text"
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"
Dynamic: license-file

<p align="center"><img src="https://raw.githubusercontent.com/Spikeon-Studio/part-grimoire/main/docs/assets/banner.png" alt="part-grimoire: a terminal tool to materialize CAD from code grimoires" width="100%"></p>

# part-grimoire

[![Test](https://github.com/Spikeon-Studio/part-grimoire/actions/workflows/test.yml/badge.svg)](https://github.com/Spikeon-Studio/part-grimoire/actions/workflows/test.yml)
[![PyPI](https://img.shields.io/pypi/v/part-grimoire)](https://pypi.org/project/part-grimoire/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](https://github.com/Spikeon-Studio/part-grimoire/blob/main/LICENSE)

part-grimoire turns a part, written as a config file and Python CAD code, into a folder with everything to make it. It operates in the terminal, on your own computer, one stage after the other.

You write a **chapter**: a **rubric** (`rubric.toml`) and an **incantation** (a [badcad](https://github.com/spikeon/badcad) Python file). Then you **cast** it. The cast writes a **page** for each aspect (variant) of the part. It seals each page into a **spell** (a zip file). A page has:

- an STL and a STEP file for each **talisman** (printed piece)
- a **glyph** (a DXF outline) of each talisman
- the **bound form** (the assembled part) as STL, 3MF, and STEP, with one named, coloured solid for each item
- the **sigil** (thumbnail) and an **illumination** (picture) of each talisman
- an exploded view of each **rite** (assembly step), and **the unveiling** (an exploded view of all the rites)
- the **manifestation**: a Bambu Studio print project and a sliced plate, with the print time and the filament weight
- the **reagents** (the bill of materials) as CSV, JSON, and Markdown
- the page text (a README) and the **colophon** (the build record)

The [glossary](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/glossary.md) gives the plain meaning of each term. part-grimoire is a terminal version of the model build pipeline of ExoWorks.

## Install

### With pip

```bash
pip install part-grimoire
```

pip installs part-grimoire and its Python packages. It does not install the system libraries or the familiar (Bambu Studio). Without the familiar, use `cast --no-manifest`. `part-grimoire augur` shows what is missing.

### With the installer

The installer installs everything, the familiar included:

```bash
git clone https://github.com/Spikeon-Studio/part-grimoire.git
```

```bash
cd part-grimoire && ./install.sh
```

The installer installs:

1. The system packages: Python, git, the OpenGL and EGL libraries, Xvfb, and the cairo headers. It uses `apt`, `dnf`, `pacman`, or `zypper`, and `sudo` prompts you for your password.
2. A Python environment in `~/.local/share/part-grimoire/venv` with badcad, build123d, manifold3d, OCP, numpy, scipy, shapely, Pillow, moderngl, matplotlib, ezdxf, and pycairo.
3. The `part-grimoire` command in `~/.local/bin`.
4. The familiar (Bambu Studio): the Docker image `ghcr.io/spikeon/bambu-studio-mcp:latest` if Docker is on the computer, else `com.bambulab.BambuStudio` from Flathub.

Then it starts `part-grimoire augur`, which checks each dependency.

| Installer option | Effect |
| --- | --- |
| `--familiar docker` | Use the Docker image of Bambu Studio. Install Docker if it is missing. |
| `--familiar flatpak` | Use Bambu Studio from Flathub. Install Flatpak if it is missing. |
| `--familiar skip` | Do not install Bambu Studio. The casts make no manifestation. |
| `--no-system` | Do not install system packages. |
| `--dev` | Make an editable install with the test tools. |
| `--uninstall` | Remove the environment, the command link, and the settings. |

## Quick start

```bash
part-grimoire inscribe my-box
```

```bash
part-grimoire cast my-box
```

The page is in `my-box/pages/my-box/`, and the spell is `my-box/pages/my-box.spell.zip`. To find and store a good camera for each picture:

```bash
part-grimoire divine my-box
```

## Commands

| Command | Effect |
| --- | --- |
| `part-grimoire cast [chapter]` | Cast the spell: make the page and the spell of each aspect. |
| `part-grimoire divine [chapter]` | Find the cameras of the views and store them in `visions.toml`. `--jev` lets Jev find. |
| `part-grimoire scry [chapter]` | Read the chapter. Show the talismans, the rites, and the reagent cost. Write nothing. |
| `part-grimoire inscribe <folder>` | Make a chapter with an example part. |
| `part-grimoire augur` | Check that the computer has all the dependencies. |
| `part-grimoire lore <machine\|process\|filament>` | List the Bambu Studio profiles. |

The [command reference](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/cli.md) gives all the options.

## A chapter

`rubric.toml`:

```toml
[chapter]
name = "cable-clip"
title = "Cable Clip"
version = "2.1"
incantation = "clip.py"

[aspects]
cable = [4, 6, 8]

[tinctures]
latch = "#d2691e"

[reagents."M3x12 screw"]
kind = "screw"
d = 3
length = 12
price = 7.49
pack = 100

[rites.latch]
title = "Attach the latch"
text = "Put the latch on the base. Install the screw."
camera = [-35, 15]

[manifestation]
printer = "Bambu Lab P1S 0.4 nozzle"
```

`clip.py`:

```python
from partgrimoire import Ritual


def talismans(cable):
    return {"base": base(), "latch": latch(cable)}


def ritual(talismans, cable):
    r = Ritual()
    r.rite("latch")
    r.talisman("base", talismans["base"])
    r.talisman("latch", talismans["latch"], rite="latch", explode=0.8)
    r.reagent("M3x12 screw", at=(-9, 0, 6 + cable + 4.8), axis=(0, 0, 1), rite="latch", explode=2.0)
    return r
```

The full example is in [`examples/cable-clip`](https://github.com/Spikeon-Studio/part-grimoire/tree/main/examples/cable-clip).

## Cameras

Each picture can store its own camera (`camera`, `zoom`, `center`) in the rubric. `part-grimoire divine` finds cameras that show the items best, and stores them in `visions.toml`. With `--jev`, the Jev decision model finds from the best cameras. Jev is optional, and a stored camera always wins. See [Scrying and cameras](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/scrying.md).

## Documentation

| Page | Contents |
| --- | --- |
| [Get started](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/getting-started.md) | Install, inscribe, scry, cast, and divine |
| [The incantation](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/incantation.md) | `talismans()`, `ritual()`, and the `Ritual` methods |
| [Scrying and cameras](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/scrying.md) | The pictures, the stored cameras, `divine`, and Jev |
| [Reagents](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/reagents.md) | Hardware items, prices, and the reagent list |
| [The familiar](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/familiar.md) | Bambu Studio: backends, profiles, and print settings |
| [The page](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/page.md) | The outputs, the glyphs, the colophon, and the seal |
| [Rubric reference](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/rubric.md) | Each table and key, with its type and default |
| [Command reference](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/cli.md) | All commands and options |
| [Glossary](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/glossary.md) | The grimoire terms |
| [Troubleshooting](https://github.com/Spikeon-Studio/part-grimoire/blob/main/docs/troubleshooting.md) | Errors and their causes |

## Tests

```bash
./install.sh --dev
```

```bash
~/.local/share/part-grimoire/venv/bin/python -m pytest
```

The tests use only the fixture chapter in `tests/fixtures`. They do not start the familiar or Jev. GitHub Actions does the tests on Python 3.12 and 3.14 for each push to `main` and each pull request.
