Skip to content

prwang/Easy-ECAD-Downloader-Offline

Repository files navigation

EasyEDA-to-ECAD Converter

Standalone pipeline that downloads JLCPCB/LCSC part data from the EasyEDA API and converts it to Altium Designer (.schdoc + .pcbdoc) or KiCad (.kicad_sym + .kicad_mod) library files — no EasyEDA client required.

Quick start

# Altium (primary — no browser, no login)
./run_altium.sh C125116

# Altium via browser (defensive — uses the open page's cookies/session)
./run_altium.sh --browser --lcsc-id C125116

# KiCad (requires browser for LCSC ID auto-detection)
./run.sh --lcsc-id C125116

Output lands in output_altium/ (Altium) or output/ (KiCad).

Why two paths?

The EasyEDA component API is open-access — no authentication, no API key. The Node.js path calls it directly with fetch().

The browser path exists as defense-in-depth: all HTTP requests go through the browser's window.fetch, inheriting its cookies, User-Agent, and TLS fingerprint. If JLCPCB ever puts the API behind Cloudflare anti-bot, you open a product page in headed Chrome (playwright-cli open --headed), solve any challenge, then run the conversion — the API call piggybacks on that authenticated session. No curl, no mixed origins.

Architecture

┌──────────────────────────────────────────────────┐
│                  EasyEDA API                      │
│  easyeda.com/api/products/{id}/components         │
│  (open — no auth)                                │
└──────────────┬───────────────────────────────────┘
               │
       ┌───────┴────────┐
       │  fetchCadData() │
       │  JSON → object  │
       └───────┬────────┘
               │
    ┌──────────┴──────────┐
    │   parseEasyeda*()   │  ← adapted CJS ports from Easy-ECAD-Downloader
    │   normalized model  │    (AGPL-3.0, see License section)
    └──────┬──────┬───────┘
           │      │
    ┌──────┴┐    ┌┴─────────┐
    │Symbol │    │Footprint │
    │Emitter│    │ Emitter  │  ← original Altium emitters
    └───┬───┘    └┬─────────┘
        │          │
   ┌────┴────┐ ┌──┴──────────┐
   │.schdoc  │ │.pcbdoc      │
   │Protel   │ │Protel       │
   │Schematic│ │Advanced PCB │
   └─────────┘ └─────────────┘

Coordinate mapping

EasyEDA source Altium target Conversion
Symbol pin position (internal units) Schematic units (10-mil grid) 1:1
Symbol graphics (rect, circle) Schematic units 1:1
Footprint pad position (internal) mils ×10
Footprint pad size (internal) mils ×10
Footprint Y-axis Y-down negated
Pad hole radius HOLESIZE (diameter, mils) ×2×10
Pad shapes: ELLIPSE→ROUND, RECT→RECTANGLE, OVAL→ROUND

File inventory

Altium pipeline (original work)

File Purpose
convert_altium.js Pure Node.js CLI — fetch API → convert → write files. No browser.
altium_converter_core.js Orchestrator: parses EasyEDA data, calls emitters.
altium_symbol_emitter.js Converts parsed symbol model → Altium .schdoc ASCII (Protel 5.0).
altium_footprint_emitter.js Converts parsed footprint model → Altium .pcbdoc ASCII (Protel 5.00).
fetch_convert_altium.js Self-contained IIFE for playwright-cli eval (browser path). Inlines all parsers + emitters.
run_altium.sh Bash wrapper — dispatches Node.js path (default) or browser path (--browser).

Shared parsers (adapted from Easy-ECAD-Downloader, AGPL-3.0)

File Purpose
easyeda_symbol_parser.js CJS port of Easy-ECAD-Downloader/src/kicad/easyeda_symbol_parser.js. Parses P/R/C/PL/PG/PT/A/E shape tokens from the API dataStr.shape array into a normalized symbol model.
easyeda_footprint_parser.js CJS port of Easy-ECAD-Downloader/src/kicad/easyeda_footprint_parser.js. Parses PAD/TRACK/HOLE/VIA/CIRCLE/ARC/RECT/TEXT/SVGNODE tokens into a normalized footprint model.

Analysis & development tools

File Purpose
altium_corpus_parser.js Parses Altium Protel ASCII .schdoc/.pcbdoc files to JSON for comparison.
correlate.js Cross-references EasyEDA API responses against corpus .schdoc/.pcbdoc files to verify the structural mapping. Used during development to confirm coordinate conversions.

KiCad pipeline (derived from Easy-ECAD-Downloader, AGPL-3.0)

File Purpose
fetch_convert.js IIFE bundle — inlines all 9 KiCad converter source files from Easy-ECAD-Downloader/src/.
run.sh Bash wrapper — playwright-cli eval → JSON extraction → writes .kicad_sym/.kicad_mod.
detect_part.js Content script that inspects product pages and returns LCSC ID + provider metadata.

Data

Path Purpose
api_responses/ Cached EasyEDA API responses for offline testing (6 parts). Not needed at runtime.
output/ Generated KiCad files.
output_altium/ Generated Altium files.

Relationship to Easy-ECAD-Downloader

This project is inspired by Easy-ECAD-Downloader by JoeShade (AGPL-3.0), but is a separate, standalone project with a different scope:

Aspect Easy-ECAD-Downloader This project
Target format KiCad only Altium (primary) + KiCad
Runtime Browser extension (CRX) CLI scripts (Node.js / playwright)
EasyEDA client Relies on EasyEDA Pro editor No EasyEDA client needed — calls API directly
Altium support None Full .schdoc + .pcbdoc generation
Symbol/footprint emitters KiCad S-expr Altium Protel ASCII

What was reused (under AGPL-3.0 §5):

  • easyeda_symbol_parser.js and easyeda_footprint_parser.js are CJS ports of the upstream ESM parsers. They parse the same EasyEDA shape token format (PRC… for symbols, PADTRACK~… for footprints) into the same intermediate model. Ported because the upstream parsers use ESM import/export, incompatible with playwright-cli eval's single-expression requirement.
  • fetch_convert.js bundles the upstream KiCad emitters for the KiCad path.

What is original:

  • All Altium emitters (altium_symbol_emitter.js, altium_footprint_emitter.js) — these target a completely different output format (Protel ASCII, not KiCad S-expressions).
  • altium_converter_core.js, convert_altium.js, fetch_convert_altium.js, run_altium.sh, correlate.js, altium_corpus_parser.js.
  • The coordinate mapping (EasyEDA internal ×10→mils, Y-axis negation, pad shape remapping) was derived empirically by correlating EasyEDA API responses against known-good Altium exports, not from upstream code.

Usage

Altium (Node.js — no browser)

# From an LCSC part number
./run_altium.sh C125116

# or directly with node:
node convert_altium.js C2677725 --out ./my_libs
node convert_altium.js C5328753 --symbol-only
node convert_altium.js C2847242 --footprint-only

Altium (browser — defensive)

# 1. Open a JLCPCB product page in headed Chrome
playwright-cli open --headed https://jlcpcb.com/partdetail/LITEON-LTST-S326KGJRKT/C125116

# 2. Run conversion (auto-detects LCSC ID from page)
./run_altium.sh --browser

# Or with explicit ID (still uses browser's fetch, not Node.js)
./run_altium.sh --browser --lcsc-id C125116

KiCad

./run.sh --lcsc-id C125116

Dependencies

  • Node.js ≥ 20 (for native fetch())
  • playwright-cli (optional — only needed for --browser path or KiCad pipeline)
  • No npm packages required

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0), inheriting from Easy-ECAD-Downloader. See the LICENSE in the upstream repository.

The Altium emitters, converter core, correlation tools, and CLI scripts are original work. The EasyEDA symbol/footprint parsers are adapted CJS ports of upstream AGPL-3.0 code. Attribution is maintained in each file's header.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors