Metadata-Version: 2.5
Name: cad-to-bom
Version: 0.2.0
Summary: Bill of materials, build checklist and cost tracker for CAD projects: shop listings across Amazon and AliExpress, alternatives with spec checks, 3D printed parts from your exports.
Project-URL: Homepage, https://github.com/moaazsidat/cad-to-bom
Project-URL: Source, https://github.com/moaazsidat/cad-to-bom
Project-URL: Issues, https://github.com/moaazsidat/cad-to-bom/issues
Project-URL: Changelog, https://github.com/moaazsidat/cad-to-bom/releases
Author: cad-to-bom contributors
License-Expression: MIT
License-File: LICENSE
Keywords: 3d printing,bill of materials,bom,build123d,cad,checklist
Classifier: Environment :: Web Environment
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.11
Provides-Extra: test
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://cadtobom.dev"><img src="https://raw.githubusercontent.com/moaazsidat/cad-to-bom/main/brand/logo-lockup.svg" width="640" alt="cad-to-bom"></a>
</p>

<p align="center"><b>Turn your CAD into a parts list. Your agent does the shopping.</b></p>

<p align="center">
  <a href="https://cadtobom.dev">Website</a> ·
  <a href="#reference">Docs</a> ·
  <a href="skills/cad-to-bom/SKILL.md">Agent skill</a>
</p>

<p align="center">
  <a href="https://pypi.org/project/cad-to-bom/"><img src="https://img.shields.io/pypi/v/cad-to-bom?label=cad-to-bom" alt="PyPI"></a>
  <a href="https://github.com/moaazsidat/cad-to-bom/actions/workflows/ci.yml"><img src="https://github.com/moaazsidat/cad-to-bom/actions/workflows/ci.yml/badge.svg" alt="Tests"></a>
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"></a>
</p>

## Quickstart

macOS and Linux:

```bash
curl -fsSL https://cadtobom.dev/install.sh | sh
```

Windows (PowerShell):

```powershell
irm https://cadtobom.dev/install.ps1 | iex
```

The installer installs [uv](https://docs.astral.sh/uv/) if it is missing, then the `cad-to-bom` command, then the [cad-to-bom skill](skills/cad-to-bom/SKILL.md) in each agent app it finds (Claude Code, Codex, and `~/.agents/skills` for others). Run it again, or `cad-to-bom update`, to update. To install only the command: `uv tool install cad-to-bom` or `pip install cad-to-bom`.

As a plugin, in Claude Code:

```
/plugin install cad-to-bom --marketplace moaazsidat/cad-to-bom
```

The repository is a plugin for Codex, Cursor and Gemini CLI too. A plugin brings the skill; the command still comes from the installer or uv. More in [docs/install.md](docs/install.md).

Then ask your agent for a parts list:

> Read `BOM.md` and the STL exports in `lamp/`, and write `lamp/bom.toml` with specs for anything with a size or rating.

> Find every part on amazon.ca and AliExpress. Record the listings, and mark cheaper substitutes as alternatives.

> What's left to buy, what needs my review, and what does it cost in CAD?

The agent writes `bom.toml`, finds listings with its browser and records them with the CLI. You review everything in a local page: `cad-to-bom serve -c lamp --open`. Try it on the example with `cad-to-bom serve -c examples/desk-lamp --open`.

## Features

- [Bought parts](#bomtoml) from `bom.toml`, each linked to listings in any Amazon store, AliExpress or a shop you add.
- [Printed parts](#using-it-with-text-to-cad) from your STL and 3MF exports, each with a 3D preview, its size and a filament cost estimate.
- [Spec checks](#alternatives-spec-checks-and-approval): alternatives sit beside the original listing. Listings that don't match the part's specs are flagged and stay out of the total until you approve them.
- [Costs](#costs) in any [currency](#currencies), with pack sizes handled: 4 screws from a 100-pack costs the whole pack.
- A build checklist: each part is *to buy*, *ordered* or *have*, with notes. Filter, sort and search.
- [An agent skill](skills/cad-to-bom/SKILL.md) that teaches the workflow, and a [CLI](#command-line) for every action, so an agent never has to drive the page.
- Plain files: it runs locally with no dependencies, and your progress is a JSON file you commit next to your design.

It works with any agent that supports skills, or any agent with a shell.

## Reference

### bom.toml

```toml
title = "My robot"
currency = "USD"                                  # default display currency
markets = ["amazon.com", "amazon.ca", "aliexpress"]

[[sections]]
id = "drive"
title = "Drive"

[[parts]]
section = "drive"
qty = 2                                           # a number, or text such as "1 m", "~60" or "4 + 2"
# buy = 1                                         # optional: how many listings to buy, when qty doesn't say
name = "608-2RS bearing"
search = "608 2RS bearing"                        # optional; the default is name
notes = "lead screw ends"
specs = { bore_mm = 8, od_mm = 22, width_mm = 7, seal = "2RS" }

  [[parts.links]]                                 # optional: listings can also be added on the page
  market = "amazon.com"
  url = "https://..."
  price = 9.99                                    # in the market's currency unless currency = "..." is set
  pack = 10
  specs = { bore_mm = 8, od_mm = 22, width_mm = 7, seal = "2RS" }

[[printed]]
section = "drive"
paths = ["STL/*.stl", "3MF/*.3mf"]                # globs, relative to bom.toml
material = "PETG"
qty = { motor_mount = 2 }                         # or name a file part_x2.stl

[printing]
price_per_kg = { PLA = 20, PETG = 22 }            # or a single number
currency = "USD"                                  # defaults to the project currency
fill = 0.6                                        # printed mass as a fraction of a solid part; a rough estimate
density = { PETG = 1.27 }                         # g/cm³; common materials are built in
```

Each part gets a stable id made from its section and name, such as `drive-bought-608-2rs-bearing`. Your progress is stored under that id. If you rename a part, set `id = "..."` on it to keep its history.

#### Marketplaces

The built-in marketplaces are:

- Amazon: `amazon.com`, `amazon.ca`, `amazon.co.uk`, `amazon.de`, `amazon.fr`, `amazon.it`, `amazon.es`, `amazon.nl`, `amazon.se`, `amazon.pl`, `amazon.co.jp`, `amazon.com.au`, `amazon.in`, `amazon.com.mx`, `amazon.com.br`, `amazon.sg`, `amazon.ae`
- `aliexpress`

You can add any other shop, or override a built-in one:

```toml
markets = [
  "amazon.co.uk",
  { id = "aliexpress", currency = "EUR" },        # the currency your AliExpress account shows
  { id = "mcmaster", name = "McMaster-Carr", currency = "USD", search = "https://www.mcmaster.com/{q}" },
]
```

#### Finding parts

cad-to-bom does not scrape shops. Each part shows a **Find** link for every marketplace, which opens that shop's search for the part. When you choose a listing, paste its URL, price and pack size into the side panel, or use the CLI (`cad-to-bom link ...`). Because the CLI and the JSON API are plain, a browser agent can fill in listings for you.

#### Alternatives, spec checks and approval

Each marketplace can hold one **original** listing (the part as specified) and any number of **alternatives**.

- Give the part `specs`, and give each listing the specs it states. A listing's specs that don't match the part's, or that the listing doesn't state, show as a diff.
- A listing **needs review** if it is an alternative, or if its specs differ from the part's. Until you approve it:
  - the part is flagged (filter: *Review*);
  - the listing is left out of the cost.
- **Approve fit** marks it checked. **Reject** keeps it on record with a reason, so you don't evaluate it again.
- If you change a listing's URL or specs, its verdict goes back to *unverified*.

From the CLI:

```bash
cad-to-bom link drive-bought-608-2rs-bearing aliexpress https://... --alt --price 3.20 --pack 10 \
    --spec bore_mm=8 --spec od_mm=22 --spec width_mm=7 --spec seal=ZZ
cad-to-bom list --listings                        # shows verdicts and diffs
cad-to-bom verify drive-bought-608-2rs-bearing l2 rejected --reason "ZZ shields, need 2RS seals"
```

#### Currencies

Prices are stored in the currency they were listed in, and converted when shown; converted prices are marked `≈`. Rates are the European Central Bank's daily reference rates, fetched from [frankfurter.app](https://frankfurter.app) and cached for 12 hours in `.cad-to-bom/`. To work offline, or to pin rates, set them per USD:

```toml
[fx]
rates = { CAD = 1.40, GBP = 0.79 }
```

#### Costs

- **A bought part's cost** is the number of packs needed times the pack price. A quantity with a unit ("375 g", "2 m") counts as one listing; set `buy = n` on the part to say otherwise. It uses the listing you mark "use for cost"; otherwise it uses the cheapest usable listing.
- **A printed part's cost** is mesh volume × density × fill × price per kg. Treat it as an estimate.
- **The top bar** shows the total, what you have spent so far (*ordered* plus *have*), what is still to buy, and how many parts have no price yet.

### Using it with text-to-cad

Export your printed parts from the models. You can do this one at a time:

```bash
cadgen export <model id> STL/bracket.stl
```

Or let the project's `exports.py` write them all. Then list the folders in `[[printed]]`. The page rescans on every load, so a fresh export appears when you reload.

To print more than one copy of a part, add `_x<n>` to its file name (`clip_x4.stl`) or set a `qty` table.

### Command line

| Command | What it does |
| --- | --- |
| `cad-to-bom init [dir]` | Writes a starter `bom.toml`. |
| `cad-to-bom serve [-c bom.toml] [--host] [--port] [--open]` | Serves the page. |
| `cad-to-bom list [--missing] [--listings] [--currency EUR] [--json]` | Lists items, their listings and diffs. |
| `cad-to-bom summary [--currency EUR]` | Shows cost totals per section. |
| `cad-to-bom search [ids...] [--market amazon.de] [--open]` | Prints search links for parts that have no listing. |
| `cad-to-bom link <id> <market> <url> [--price] [--pack] [--currency] [--alt] [--spec k=v]` | Records a listing. |
| `cad-to-bom verify <id> <listing> approved\|rejected\|unverified [--reason]` | Records whether a listing fits. |
| `cad-to-bom status todo\|ordered\|have <ids...>` | Sets the status of one or more parts. |
| `cad-to-bom import-md BOM.md` | Turns markdown BOM tables (with Qty and Part columns) into `[[parts]]`. |
| `cad-to-bom doctor [-c bom.toml]` | Checks the install, the agent skill and the project. Include its output in bug reports. |
| `cad-to-bom update [--skill-only]` | Upgrades cad-to-bom with uv and refreshes the agent skill. |

While `serve` is running, the page uses a small JSON API: `GET /api/project?cur=EUR` returns the full report, and `POST /api/item` with `{"id": ..., ...}` updates an item.

### Files

| File | Contents | Commit it? |
| --- | --- | --- |
| `bom.toml` | What the design needs. | Yes. |
| `bom-state.json` | Status, notes, listings and verdicts, written by the page and the CLI. | Yes, to share progress; ignore it to keep progress private. |
| `.cad-to-bom/` | Cached exchange rates and mesh measurements. | No. |

### Security

`serve` listens on `127.0.0.1` and has **no authentication**. Anyone who can reach the port can read and edit your BOM. To use it from other devices, put it behind something that does authenticate, such as an SSH tunnel, a VPN, or `tailscale serve`, rather than binding to `0.0.0.0` on an untrusted network.

## Community

- [text-to-cad](https://github.com/earthtojake/text-to-cad): design physical products with AI. cad-to-bom turns its exports into a parts list.
- [build123d](https://github.com/gumyr/build123d): the Python CAD library text-to-cad builds on.
- [uv](https://github.com/astral-sh/uv): installs cad-to-bom.

## Contributing

Bug reports are welcome in [issues](https://github.com/moaazsidat/cad-to-bom/issues): include the output of `cad-to-bom doctor -c <your project>` and your `bom.toml` (or the part of it that matters). If the skill made your agent do the wrong thing, say what it did; that's as useful as a fix. Skill changes go in [`skills/cad-to-bom/`](skills/cad-to-bom/).

[CONTRIBUTING.md](CONTRIBUTING.md) covers setting up a checkout and testing a change in an agent app; [AGENTS.md](AGENTS.md) is the map of the repository. Report security problems privately, as [SECURITY.md](SECURITY.md) says.

## License

MIT
