Metadata-Version: 2.4
Name: kicad2easyeda
Version: 0.1.0
Summary: Export KiCad projects (schematic + PCB) to EasyEDA Standard format
Author: Rayhan R. Zamzamy
License-Expression: GPL-3.0-or-later
Keywords: kicad,easyeda,lceda,jlcpcb,pcb,eda,converter
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Manufacturing
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Dynamic: license-file

# kicad2easyeda

Export a KiCad project (schematic + PCB) to an **EasyEDA Standard** project.
EasyEDA Pro (also the editor inside JLCONE) can import EasyEDA Standard files too.

The tool reads the KiCad files directly. It has no dependencies (Python 3.10+ standard
library only), does not need KiCad installed, and ignores S-expression tokens it does not
know, so files from newer KiCad versions still load. It was developed against KiCad 10.

## Install

```
pip install kicad2easyeda
# or the latest code
pip install git+https://github.com/hanzamzamy/kicad2easyeda
```

`pipx install .` works too if you only want the command.

## Usage

```
kicad2easyeda path/to/project.kicad_pro -o easyeda_out
```

The argument can be a `.kicad_pro`, `.kicad_pcb` or `.kicad_sch` file, or a project folder.
`python3 -m kicad2easyeda ...` works without installing.

From Python:

```python
from kicad2easyeda import export_project

result = export_project("path/to/project.kicad_pro", "easyeda_out")
print(result.files)   # {'pcb': ..., 'schematic': ..., 'backup': ..., 'report': ...}
print(result.notes)   # everything that could not be mapped 1:1
```

Output:

| File | Use |
|---|---|
| `PCB_<name>.json` | EasyEDA Std: File > Open > EasyEDA... |
| `SCH_<name>.json` | EasyEDA Std: File > Open > EasyEDA... (all sheets in one document) |
| `BackupProjects_<name>.zip` | Both documents packaged like an EasyEDA Std project backup |
| `<name>_export_report.txt` | Renamed nets and everything that could not be mapped 1:1 |

Options: `--no-sch`, `--no-pcb`, `--name NAME`, `-q`, `--version`.

## What is converted

**PCB**
- Tracks, arcs and vias.
- Pads: rect, round, oval, rounded-rect, chamfered, trapezoid and custom shapes; slots,
  plated and non-plated holes, mask and paste margins.
- Footprints and symbols, with part numbers mapped to the EasyEDA BOM attributes. Field names
  are matched loosely: `LCSC ID`, `LCSC Part #`, `JLCPCB Part`... (any field with "LCSC" or
  "JLC" holding a `C123456` number), plus `MPN` / `Manufacturer Part` and `Manufacturer`.
- Copper zones, including their current fill, priority, clearance, thermal and island settings.
- Rule-area pour keepouts.
- Graphics on all layers, and the board outline.
- Text: rendered with KiCad's own stroke font, so the silkscreen matches KiCad.
- TrueType text (e.g. a custom logo font) and knockout text: exported as filled silkscreen
  shapes from KiCad's cached outlines, exactly as KiCad draws them. They are not editable
  text in EasyEDA, because EasyEDA would redraw them in a substitute font, at a different
  size and position.
- QR-code barcodes: module-for-module identical to KiCad's.
- Dimensions.

**Schematic**
- Every sheet instance becomes an EasyEDA sheet.
- Symbols, with their exact KiCad graphics and pins.
- Wires, junctions, no-connects and text. Multi-line text is split into one item per line,
  placed exactly as KiCad justifies it.
- Labels, power symbols and global labels become EasyEDA net labels, net flags and net ports.
- Multi-unit parts get EasyEDA's `U1.1` / `U1.2` designators.

## Net names

EasyEDA Std has no hierarchy: every net label with the same name is connected across all
sheets. So all labels are written with the **full KiCad net name** (e.g. `/Power/V_SYS`),
taken from the PCB pads. This keeps sheet-local nets apart, and the schematic and PCB net
names identical.

KiCad text markup is flattened, because `~` and `^^` are separators in the EasyEDA format:

| KiCad | EasyEDA |
|---|---|
| `~{RST}` | `RST#` |
| `V_{BAT}` | `V_BAT` |
| `I^{2}C` | `I2C` |

## Known limitations

These are listed per project in the report.

- No hierarchy: sheet symbols become drawn boxes. Buses are not converted.
- Things EasyEDA Std cannot represent:
  - DNP markers
  - "exclude from board" flags
  - knockout text in KiCad's stroke font (TrueType knockout text is exported)
  - per-pad "no paste" / "no mask"
  - blind / buried vias
  - hatched zones
- 3D models are not exported. EasyEDA uses its own model library.

## Development

```
pip install -e ".[test]"
pytest
```

The tests export a small KiCad 10 demo project (`tests/fixtures/demo`) and check the
documents: field layout, connectivity under EasyEDA's rules, BOM attributes and text placement.

### Verification tools

These need KiCad (`kicad-cli`, and the `pcbnew` Python module for the PCB check).

- `tools/roundtrip_pcb.py board.kicad_pcb PCB_x.json`: re-imports the export with KiCad's own
  EasyEDA importer and compares footprints, every pad, track, via, zone and net.
- `tools/check_sch.py root.kicad_sch SCH_x.json`: compares KiCad's netlist with the connectivity
  EasyEDA would derive from the exported schematic.
- `tools/preview_sch.py SCH_x.json outdir`: SVG preview of the exported sheets.
- `tools/build_font.py newstroke_font.cpp`: regenerates `kicad2easyeda/newstroke.json` from
  KiCad's source.

## License

GPL-3.0-or-later (see `LICENSE`). `kicad2easyeda/newstroke.json` is derived from KiCad's
newstroke font (GPL-2.0-or-later). The QR encoder follows Project Nayuki's algorithm.
