Rename scripts to capacitors, locations, bottom_termination; update README and .env
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
38
README.md
38
README.md
@@ -59,35 +59,27 @@ Finds all **two-pad components** on the PCB that share the same two nets (e.g. d
|
||||
}
|
||||
```
|
||||
|
||||
### Protel PCB 2.8 ASCII — easier (Python, no Altium)
|
||||
### KiCad .kicad_pcb (Python script)
|
||||
|
||||
**Yes — Protel PCB 2.8 ASCII is easier.** It’s plain text, so you can parse it with Python and no OLE/binary handling. You don’t need Altium running.
|
||||
**Script:** `capacitors_by_net_pair.py` — **KiCad only.** Reads a `.kicad_pcb` file and outputs the same JSON (net pair → capacitors with designator, value, package, total capacitance).
|
||||
|
||||
1. **Export from Altium:** Open your PcbDoc → **File → Save As** (or **Export**) → choose **PCB 2.8 ASCII** or **Protel PCB ASCII** if your version offers it. Some versions use **File → Save Copy As** with format “PCB Binary/ASCII” or similar.
|
||||
2. **Run the Python script** on the exported `.pcb` / `.PcbDoc` (ASCII) file:
|
||||
|
||||
```bash
|
||||
python3 capacitors_by_net_pair.py board.PcbDoc
|
||||
python3 capacitors_by_net_pair.py board.PcbDoc -o out.json
|
||||
```
|
||||
|
||||
**Input/output from .env:** Copy `.env.example` to `.env` and set `INPUT_FILE` and `OUTPUT_FILE`. The script reads these when the optional `python-dotenv` package is installed; CLI arguments override them. Without `.env`, you can still pass the input file and `-o` on the command line. By default the JSON is written to **`outputs/capacitors_by_net_pair.json`** (the `outputs/` directory is created if needed).
|
||||
|
||||
See **`capacitors_by_net_pair.py`** for the script. It parses COMP/PATTERN/VALUE and NET/PIN data from the ASCII file and produces the same JSON shape as the DelphiScript.
|
||||
|
||||
**Test file:** `tests/sample_protel_ascii.pcb` is a minimal Protel PCB 2.8 ASCII sample. Run:
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
python3 capacitors_by_net_pair.py tests/sample_protel_ascii.pcb -o tests/out.json
|
||||
python3 capacitors_by_net_pair.py board.kicad_pcb
|
||||
python3 capacitors_by_net_pair.py board.kicad_pcb -o outputs/capacitors_by_net_pair.json
|
||||
```
|
||||
|
||||
**Input/output from .env:** Set `INPUT_FILE` and `OUTPUT_FILE`; CLI overrides. Default output: **`outputs/capacitors_by_net_pair.json`**.
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Compare component locations (two Protel files)
|
||||
## Compare component locations (two KiCad files)
|
||||
|
||||
**Script:** `compare_protel_locations.py`
|
||||
|
||||
Loads two Protel PCB 2.8 ASCII files and reports **which components have moved** between them. Component position is the centroid of pin coordinates. Output is written to `outputs/compare_locations.json` by default.
|
||||
Loads two KiCad `.kicad_pcb` files and reports **which components have moved** between them. Component position is the centroid of pad `(at x y)` coordinates. Output is written to `outputs/compare_locations.json` by default.
|
||||
|
||||
- **Moved:** designators with different (x, y) in file2, with old position, new position, and distance.
|
||||
- **Only in file1 / only in file2:** components that appear in just one file.
|
||||
@@ -95,18 +87,12 @@ Loads two Protel PCB 2.8 ASCII files and reports **which components have moved**
|
||||
**Usage:**
|
||||
|
||||
```bash
|
||||
python3 compare_protel_locations.py board_v1.pcb board_v2.pcb
|
||||
python3 compare_protel_locations.py board_v1.pcb board_v2.pcb -o outputs/compare_locations.json
|
||||
python3 compare_protel_locations.py board_v1.kicad_pcb board_v2.kicad_pcb
|
||||
python3 compare_protel_locations.py board_v1.kicad_pcb board_v2.kicad_pcb -o outputs/compare_locations.json
|
||||
```
|
||||
|
||||
Use **.env** (optional): set `FILE1`, `FILE2`, and `COMPARE_OUTPUT`; CLI arguments override them. Use `--threshold N` to set the minimum position change to count as moved (default 1.0).
|
||||
|
||||
**Test:** `tests/sample_protel_ascii.pcb` and `tests/sample_protel_ascii_rev2.pcb` (C1 and C2 moved in rev2):
|
||||
|
||||
```bash
|
||||
python3 compare_protel_locations.py tests/sample_protel_ascii.pcb tests/sample_protel_ascii_rev2.pcb
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Spreadsheet diff by designator
|
||||
|
||||
Reference in New Issue
Block a user