Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English | 简体中文

easyeda-agent-toolkit

An automation toolkit and field guide for driving EasyEDA Pro (嘉立创EDA专业版) from an AI coding agent, built on the official easyeda-api-skill bridge.

A set of Python and PowerShell scripts that let an AI coding agent such as Claude Code operate EasyEDA Pro end to end: convert a netlist, generate a schematic, sync it to the PCB, run DRC, batch-adjust track widths and geometry, and export manufacturing files. A few operations genuinely cannot be reached through the API; those are called out explicitly in the docs, along with the UI-automation workarounds this toolkit uses.

The chain starts one step earlier than the scripts do. prompts/ holds AI-agnostic templates for the component sourcing stage — turning circuit requirements into a BOM with verified supplier part numbers — so that stage has the same evidence discipline as the automated steps that follow.

Documentation language. Every guide under docs/ and every template under prompts/ ships in both English and Chinese, distinguished by an .en.md / .zh.md suffix. The Chinese version of this README is in the second half of this same file. Script docstrings and console output remain Chinese.


Contents


Scope

What this is. Scripts that let an AI agent perform repetitive EasyEDA Pro work — bulk property edits, bulk geometry moves, bulk verification, file export — plus a written record of API behaviours that are not covered by the official documentation.

What this is not. Not an autorouter, and not a "describe a board and get a board" system. Decisions that need engineering judgement — how to close out a congested region, how to lay out the board outline, which layer a given net belongs on — remain faster to make by hand. In congested areas the marginal return of running more script passes turns negative; interactive editing is usually the quicker path there. The practical split is: scripts handle bulk rebuild and verification, a human handles the hard regions.

Why the docs matter. Several EasyEDA Pro API behaviours are counter-intuitive: property writes that report success but revert on restart, a DRC that does not check connectivity at all, a confirmation dialog that can take minutes to render, and collinear same-net segments that get merged on creation. These are not in the official reference. docs/pitfalls.en.md collects them; the pitfalls section below summarises the ones most likely to cost you a day.


Relationship to the official easyeda-api-skill

   AI agent                this repo                official easyeda-api-skill        EasyEDA Pro
 (Claude Code, ...)      (Python / PS)                 (Node bridge server)      (run-api-gateway ext.)
       │                      │                              │                            │
       │  compose a JS job    │                              │                            │
       ├─────────────────────>│                              │                            │
       │                      │  HTTP POST /execute          │                            │
       │                      ├─────────────────────────────>│                            │
       │                      │                              │   JS over WebSocket        │
       │                      │                              ├───────────────────────────>│
       │                      │                              │                            │ eda.* API
       │                      │                              │<───────────────────────────┤
       │                      │<─────────────────────────────┤        result              │
       │<─────────────────────┤  parse / verify / next pass  │                            │

The Node bridge in the middle is official EasyEDA software, not part of this repository. It comes from easyeda/easyeda-api-skill (JLCEDA, MIT). This repository contains none of its code — install it separately, as described under Setup.

What this repository adds on top:

  • tools/eda_bridge.py is an HTTP client for the bridge: it scans ports 49620–49629, reports connection status, submits a .js file as a job, and returns the JSON result. Every online script goes through it. (tel2json_netlist.py, netlist_drc.py and compare_netlist.py are fully offline and need no running EasyEDA instance.)
  • The remaining scripts are job generators and result verifiers: they assemble a JS snippet, send it through eda_bridge.py, then do the geometry, comparison and decision work in Python before generating the next snippet. Heavy computation — clearance checks, path planning, pin-by-pin netlist comparison — stays on the Python side; EasyEDA only reads and writes primitives.
  • Two PowerShell scripts use a different channel entirely: Windows UIAutomation, to click buttons in the EasyEDA UI. Some actions have no API equivalent — most importantly the confirmation dialog raised by importChanges, which the API can open but cannot dismiss.

In short: the official skill determines whether JS can reach EasyEDA; this repository determines what JS to send and how to confirm it actually took effect.


Setup

1. EasyEDA Pro desktop client

Every script here was validated against the desktop client. The two PowerShell scripts use Windows UIAutomation and therefore require Windows.

2. Install the run-api-gateway extension

Extension page: https://ext.lceda.cn/item/oshwhub/run-api-gateway

Make sure it is enabled. This extension is what connects EasyEDA to the bridge.

3. Install the official easyeda-api-skill and start the bridge

git clone https://github.com/easyeda/easyeda-api-skill.git
cd easyeda-api-skill
npm install
npm run server        # binds the first free port in 49620-49629

Follow the official README for the authoritative steps — npm script names differ between versions, and some versions require npm run build:docs first.

If you use Claude Code or another tool that supports the Agent Skills standard, put that directory somewhere the tool can read. The agent will pick up its SKILL.md and get the full API reference. This repository deliberately does not duplicate the official API documentation — look API calls up there.

4. Clone this repository

git clone https://github.com/DaCapo7/easyeda-agent-toolkit.git
cd easyeda-agent-toolkit

Requires Python 3.8+ and no third-party packages — standard library only.

For a one-click bridge launch, set SKILL_DIR inside tools/start_bridge.bat to your local easyeda-api-skill path and run it.


First commands

1. Confirm the bridge is reachable:

python tools/eda_bridge.py health

Expected:

[Bridge] 端口 49620  status=ok  窗口数=1
[嘉立创] 已连接  活动窗口=xxxx

未找到 Bridge ("bridge not found") means npm run server is not running. 嘉立创未连接 ("EasyEDA not connected") means the extension is not installed or not enabled.

The bridge must listen on dual-stack ::. EasyEDA resolves localhost to the IPv6 ::1, so an IPv4-only listener will never be found.

2. Run the first job:

python tools/eda_bridge.py run examples/00_probe.js

This lists every board in the current project with its uuid. Note the parentBoardName values — almost every script in this repository takes one as its first argument.

3. If several EasyEDA windows are open:

python tools/eda_bridge.py windows            # list connected windows
python tools/eda_bridge.py select <windowId>  # choose the active one

Always pass JS as a file (run <file>), never as a command-line string (exec "<string>"). PowerShell mangles quotes and characters such as Ω.

4. Offline check — no EasyEDA required. The repository ships a four-component demo netlist, so you can exercise the netlist stage immediately:

python tools/tel2json_netlist.py examples/demo.tel examples/out.json --bom examples/demo_bom.csv
python tools/netlist_drc.py examples/out.json

The first command reports 器件 4 | 引脚 10 | 已配料号 4/4 (4 components, 10 pins, 4/4 part numbers resolved). The second flags NC_SPARE as a net with only one pin attached, which is exactly what it is for.


Component sourcing

The chain begins before any script runs: circuit requirements have to become a BOM carrying real supplier part numbers. That stage is research, not automation, so this repository supplies prompt templates rather than code. Hand a template to any AI with web search, and finish with a verification checklist.

The templates name no AI product, assume no knowledge of your project, and mark every blank with 〈angle-bracket〉 placeholders. They work the same whichever model picks them up.

Template Purpose
prompts/component-sourcing-brief.en.md Sourcing brief: you fill in the requirements (electrical, package, temperature, cost ceiling, assembly constraints, target assembly service, supply), the AI returns a primary choice and alternates compared line by line
prompts/part-number-verification.en.md Verification checklist run before anything is written into the BOM

Chinese versions: component-sourcing-brief.zh.md, part-number-verification.zh.md. The guide docs/component-sourcing.en.md covers the stage and its handoff contract.

The rule that matters most: a C-number counts only after it has actually been retrieved from the component library — the search returned that part, stock is above zero, and package and key parameters match item by item. Part numbers are a category where language models fail quietly: the format is regular and the length fixed, so a well-formed number that does not exist, or that denotes something entirely different, is easy to emit and shows no symptom until import.

Verification runs through either the LCSC/JLCPCB web library, or through the bridge against the library the EasyEDA client is actually connected to — examples/30_library_search.js wraps eda.lib_Device.search() and eda.lib_Device.getByLcscIds() for that purpose, and reports stock, price and basic/extended library membership.

Why this belongs in the repository: every automated step downstream assumes Supplier Part is correct. If it is not, tel2json_netlist.py faithfully writes the wrong number into the netlist, the import faithfully places the wrong component, and fix_supplier_ids.py faithfully makes the wrong number more consistent. No later step ever reports that the number itself was wrong.


Workflow: from netlist to manufacturing files

The full write-up is in docs/netlist-import.en.md. The skeleton:

circuit requirements
        │  prompts/component-sourcing-brief.en.md   (sourcing research)
        │  prompts/part-number-verification.en.md   (before writing the BOM)
        ▼
.tel netlist + BOM (with verified LCSC part numbers)
        │  tel2json_netlist.py
        ▼
   netlist .json with part numbers  ──── netlist_drc.py  (offline sanity check)
        │  generate_schematic_from_json.py
        ▼
   schematic populated
        │  fix_supplier_ids.py / fix_nc.py
        ▼
   schematic DRC clean
        │  compare_netlist.py  (pin-by-pin import fidelity)
        ▼
        │  sync_pcb_via_importchanges.py
        ▼
   components and ratlines on the PCB
        │  placement / outline / routing (API or FreeRouting)
        ▼
        │  repour_safe → neck_analyze → gap_nudge → width_cut → neck_sink → fix_sink
        ▼
   DRC converged
        │  netcmp_live.py pin-by-pin regression + render_at.py visual check
        ▼
        │  export_mfg.py
        ▼
   BOM + pick-and-place, ready to order

Critical point 1: part numbers

The netlist-rebuild extension resolves library parts solely from props["Supplier Part"], the LCSC C-number. Manufacturer part number and footprint name play no role in matching. A missing part number fails the import outright; a wrong part number silently places the wrong component, and it cannot be corrected afterwardsmodify cannot change a component's library binding, so the only fix is to correct the JSON and re-import. The "component standardisation" panel in the UI does not help either; it will simply standardise to whatever the wrong part number points at.

Accordingly, tel2json_netlist.py resolves part numbers through three fallback levels (exact designator → footprint + value → unique footprint) and warns about anything it cannot resolve rather than guessing.

Critical point 2: addIntoPcb

sch_PrimitiveComponent.create(component, x, y, subPartName, rotation, mirror, addIntoBom, addIntoPcb)

Omit the last two arguments — addIntoPcb in particular — and the components exist only in the schematic. The subsequent sync to PCB then places zero components, with no error to explain why.

Critical point 3: the dialog that takes minutes

pcb_Document.importChanges(schUuid) returning true does not mean components landed on the board. It means a confirmation dialog was raised. Components are placed only when the button labelled 「应用修改」 ("Apply changes" — not 「确定」/"OK") is clicked.

On some versions that dialog takes several minutes to render. A 15- or 40-second watchdog will report "dialog never appeared" and lead you to conclude the API is broken.

sync_pcb_via_importchanges.py waits 300 seconds by default, scanning for the button throughout. If the button is not found, run list_eda_buttons.ps1 to dump the button names actually present.

Critical point 4: a clean DRC does not mean a connected board

Empirically: break a net deliberately and DRC still reports zero violations. EasyEDA's DRC covers clearance and hole geometry; it does not check connectivity.

The connectivity engine also recognises exactly coincident endpoints only — overlapping track bodies do not connect, T-junctions do not connect, and endpoints that are merely very close do not connect. Rounding coordinates to two decimal places produces an open circuit, silently.

Run netcmp_live.py as a pin-by-pin regression after every geometry pass.

Critical point 5: writes that report success but do not persist

Some API calls return success, read back the new value immediately, and still hold the old value after a restart. Confirmed cases: via hole/pad diameter, copper-pour outline width, and rule configuration passed in the wrong shape.

Reading the new value back is not verification. After changing a critical property, restart EasyEDA and read it again.


Tool reference

Everything lives in tools/, flat — the scripts call each other by same-directory relative path, so keep them together.

Bridge and UI

Script Purpose
eda_bridge.py Entry point for every online script. Finds the bridge, reports status, submits .js jobs. Subcommands: health / windows / select / run / exec
start_bridge.bat Starts the official bridge and checks the connection (set SKILL_DIR first)
click_eda_confirm.ps1 Clicks 「应用修改」 via UIAutomation. The Chinese button name is assembled from Unicode code points inside the script, bypassing every encoding layer
list_eda_buttons.ps1 Diagnostic: dumps every button name in every EasyEDA window. Use it when a version changes the button text

Netlist to schematic

Script Purpose
tel2json_netlist.py .tel + BOM → netlist JSON with part numbers. Three-level matching; warns instead of guessing
netlist_drc.py Offline check: single-pin nets, duplicate designators, connection rate. No EasyEDA needed
generate_schematic_from_json.py Builds the schematic through the bridge: library lookup → place → rename → short net-carrying wire per pin
fix_supplier_ids.py Bulk-corrects SupplierId, clearing the "supplier mismatch" DRC item
fix_nc.py Bulk-marks unused pins as NC, clearing the "floating pin" warning
compare_netlist.py Pin-by-pin diff of source netlist against the exported result, to verify import fidelity
netcmp_live.py Reads live board state and diffs it against the .tel source. Use as regression after geometry work

Schematic to PCB

Script Purpose
sync_pcb_via_importchanges.py importChanges + automatic 「应用修改」 click + polling until the count stabilises. 300 s dialog timeout by default

PCB geometry

Run in this order:

Script Purpose
repour_safe.py Safe copper repour. Verifies EasyEDA is actually the foreground window before sending Shift+B, and aborts otherwise — keystrokes must never land in another application
neck_analyze.py Violation ledger by net and by net pair, so you can see which nets are responsible
gap_nudge.py Translates violating tracks. Geometry only, no topology change; endpoints move together with segments sharing them exactly; checks for space before moving
width_cut.py Reduces over-wide violating tracks to a target width. Effective where the extra width was headroom rather than a current-carrying requirement
neck_sink.py Moves congested trunk segments to an inner layer to free surface clearance. Changes topology; backs up each net before touching it
fix_sink.py Relocates vias placed too close to the board outline or to other holes
render_at.py Screenshot of a point of interest. Look at what you changed — do not trust API return values alone

Manufacturing

Script Purpose
export_mfg.py Exports BOM and pick-and-place. Handles two traps: EasyEDA's "csv" is really UTF-16LE with tab separators, and file contents are base64-encoded across the bridge to survive console encoding

Pitfalls worth reading first

Full list in docs/pitfalls.en.md. The ten most expensive:

  1. Writes that do not persist. Via diameter and pour outline width both report success without being saved. Restart EasyEDA to verify.
  2. DRC ignores connectivity. A broken net still reports zero. Verify connectivity separately.
  3. Connectivity requires exactly coincident endpoints. Rounded coordinates mean an open circuit, with no warning.
  4. Collinear same-net segments merge on creation. To keep a junction mid-trunk, offset the junction vias a few mil alternately above and below the trunk centreline, so adjacent segments differ in slope and are not merged. Otherwise the split segments are glued back into one and the junction lands on a track body (see point 3).
  5. Primitive ids do not survive a job boundary. Read ids and use them within the same bridge job. Using them across jobs throws t.isAsync is not a function and can kill a batch halfway — with everything before that point already written, leaving a net torn in two.
  6. DRC reports phantom violations. They disappear after closeDocument and reopen. Re-check before concluding a board needs rework.
  7. Three encoding traps on Chinese Windows. Python crashes printing non-GBK characters (use sys.stdout.reconfigure); reading PowerShell output requires an explicit utf-8 encoding; EasyEDA's exported "csv" is UTF-16LE with tabs. A script that crashes while printing its own success message looks exactly like a failure.
  8. pcb_PrimitivePolyline.create(net, layer, polygon, lineWidth, primitiveLock)net comes first, and polygon must be built with the pcb_MathPolygon.createPolygon([...]) factory. Passing a bare array raises an argument error.
  9. Roughly 30 s per job. Batch accordingly: about 40 property modify calls, or about 150 geometry modify calls, per job.
  10. Before declaring a board unusable, do three things: check per-branch current, re-check after clearing phantom violations, and separate electrical problems from manufacturability problems from rule problems. Manufacturability problems — a track below the fab's minimum width, a hole below its minimum drill — are fixed by local adjustment, not by starting over.

Repository layout

easyeda-agent-toolkit/
├── README.md                 this file (English first, Chinese below)
├── LICENSE                   MIT
├── docs/                     guides, English and Chinese
│   ├── component-sourcing.{en,zh}.md   sourcing stage and its handoff contract
│   ├── netlist-import.{en,zh}.md       full netlist-to-PCB walkthrough
│   └── pitfalls.{en,zh}.md             API behaviours and pitfalls
├── prompts/                  AI-agnostic templates, English and Chinese
│   ├── component-sourcing-brief.{en,zh}.md
│   └── part-number-verification.{en,zh}.md
├── tools/                    scripts (flat; they call each other by relative path)
│   └── eda_jobs/             generated temporary JS jobs land here (not tracked)
└── examples/
    ├── 00_probe.js            connectivity probe and board listing
    ├── 10_export_netlist.js   export the resulting netlist to disk
    ├── 20_pin_truth_probe.js  pin-number probe (more reliable than a datasheet)
    ├── 30_library_search.js   library search and part-number verification
    ├── demo.tel               demo netlist, four components, runnable as-is
    ├── demo_bom.csv           matching BOM
    └── example_netlist.json   the output of that demo, and the JSON format reference

Part numbers and net names under examples/ are placeholders and correspond to no real design.


Disclaimer

This is an unofficial project with no affiliation to JLC / LCEDA / EasyEDA, and no endorsement from them. Product names and trademarks are used only to describe compatibility.

Official skill. This repository depends on easyeda/easyeda-api-skill (JLCEDA, MIT) for its bridge server and API reference, but contains, copies and redistributes none of it. Install it separately as described under Setup. Its copyright belongs to JLCEDA.

Authorship. These scripts were produced by Claude (Anthropic) in collaboration with the author. This repository is released under the MIT licence.

Use at your own risk. These scripts modify your EasyEDA project files directly, and several of them (neck_sink.py, fix_sink.py, width_cut.py, gap_nudge.py) change board geometry in bulk. Back up your project first. The author accepts no liability for design loss, production loss or cost arising from use of this toolkit. Specific behaviours — button labels, API signatures, DRC response shapes — change between EasyEDA versions; try them on a scrap board first.

Data. This repository contains no credentials, no API tokens and no private board data — no netlists, coordinates, part numbers, net names or Gerbers. Everything under examples/ is fabricated.


简体中文

English | 简体中文

嘉立创 EDA 专业版 × AI 编码代理的自动化画板工具箱与教程(基于官方 easyeda-api-skill 桥)

一套 Python / PowerShell 脚本,让 Claude Code 这类 AI 编码代理能够操作嘉立创 EDA 专业版: 转网表、生成原理图、同步到 PCB、跑 DRC、批量改线宽与几何、导下单文件。 有几个操作确实没有 API 可达,文档里会明确指出,并说明本工具箱采用的界面自动化替代方案。

链路的起点比脚本更靠前。prompts/ 放的是选型调研阶段的 AI 无关提示词模板—— 把电路需求变成一份带已核验供应商编号的 BOM——让这一段和后面的自动化步骤遵循同样的证据标准。


目录


适用范围

这是什么。 让 AI 代理执行嘉立创 EDA 专业版里重复性工作的脚本——批量改属性、批量挪几何、 批量校验、导文件——以及一份官方文档未覆盖的 API 行为记录。

这不是什么。 不是自动布线器,也不是"描述需求就出板子"的系统。 需要工程判断的决策——拥堵区怎么收口、板框怎么排、某条网该走哪层——手工仍然更快。 在窄缝区继续跑脚本的边际收益是负的,交互式编辑通常更快。 可行的分工是:脚本负责批量重建与校验,人负责难处理的区域。

文档为什么重要。 嘉立创 EDA 专业版有几类反直觉的 API 行为: 写属性返回成功但重启后还原、DRC 完全不检查连通性、确认对话框可能要几分钟才渲染出来、 共线同网的线段在创建时会被合并。这些官方参考文档里没有。 docs/pitfalls.zh.md 收集了这些行为,下面的值得先读的坑挑出了最容易耗掉一整天的那些。


与官方 easyeda-api-skill 的关系

   AI 代理                  本仓库                    官方 easyeda-api-skill        嘉立创EDA专业版
 (Claude Code 等)        (Python/PS 脚本)               (Node 桥服务)            (装 run-api-gateway 扩展)
      │                       │                              │                            │
      │   写一段 JS 作业        │                              │                            │
      ├──────────────────────>│                              │                            │
      │                       │  HTTP POST /execute          │                            │
      │                       ├─────────────────────────────>│                            │
      │                       │                              │   WebSocket 下发 JS        │
      │                       │                              ├───────────────────────────>│
      │                       │                              │                            │ eda.* API
      │                       │                              │<───────────────────────────┤
      │                       │<─────────────────────────────┤        结果回传             │
      │<──────────────────────┤   解析 / 校验 / 下一轮        │                            │

中间那个 Node 桥是嘉立创官方软件,不属于本仓库。 它来自 easyeda/easyeda-api-skill(JLCEDA,MIT 协议)。 本仓库不包含它的任何代码,请按环境准备自行安装。

本仓库在它之上补的是这些:

  • tools/eda_bridge.py 是桥的 HTTP 客户端:扫 49620–49629 端口找到桥、查连接状态、 把一个 .js 文件作为作业提交、返回 JSON 结果。所有联机脚本都从它走。 (tel2json_netlist.pynetlist_drc.pycompare_netlist.py 是纯离线的,不需要开着嘉立创。)
  • 其余脚本是作业生成器加结果校验器:拼出一段 JS,经 eda_bridge.py 发出去, 再在 Python 侧做几何、比对与决策,然后生成下一段 JS。 重计算——间距检查、路径规划、逐脚网表比对——全在 Python 侧;嘉立创只负责读写图元。
  • 两个 PowerShell 脚本走的是另一条通道:用 Windows UIAutomation 点嘉立创界面上的按钮。 有些动作没有 API 对应,最典型的就是 importChanges 弹出的确认框——API 能把它叫出来,但关不掉。

一句话:官方 skill 决定 JS 能不能送进嘉立创,本仓库决定送什么 JS、以及怎么确认它真的生效了。


环境准备

1. 嘉立创 EDA 专业版桌面客户端

本仓库全部脚本都是在桌面客户端上验证的。两个 PowerShell 脚本用了 Windows UIAutomation,需要 Windows。

2. 装 run-api-gateway 扩展

扩展页面:https://ext.lceda.cn/item/oshwhub/run-api-gateway

装完确保它处于启用状态。这个扩展负责把嘉立创连到桥。

3. 装官方 easyeda-api-skill 并起桥

git clone https://github.com/easyeda/easyeda-api-skill.git
cd easyeda-api-skill
npm install
npm run server        # 占用 49620-49629 里第一个空闲端口

具体步骤以官方 README 为准:不同版本的 npm 脚本名有出入,有的版本需要先跑 npm run build:docs

如果你用 Claude Code 或其它支持 Agent Skills 标准的工具,把那个目录放到工具能读到的地方, 代理会读它的 SKILL.md 拿到完整 API 参考。本仓库刻意不重复官方 API 文档,查 API 请看官方 skill。

4. 克隆本仓库

git clone https://github.com/DaCapo7/easyeda-agent-toolkit.git
cd easyeda-agent-toolkit

需要 Python 3.8+,无任何第三方依赖,全部标准库。

想一键起桥,把 tools/start_bridge.bat 里的 SKILL_DIR 改成你本机 easyeda-api-skill 的路径再运行。


第一条命令

1. 确认桥通了:

python tools/eda_bridge.py health

期望输出:

[Bridge] 端口 49620  status=ok  窗口数=1
[嘉立创] 已连接  活动窗口=xxxx

「未找到 Bridge」说明 npm run server 没起;「嘉立创未连接」说明扩展没装或没启用。

桥必须监听双栈 ::。嘉立创把 localhost 解析成 IPv6 的 ::1,只监听 IPv4 会连不上。

2. 跑第一个作业:

python tools/eda_bridge.py run examples/00_probe.js

它会列出当前工程里所有板及其 uuid。记下 parentBoardName——本仓库几乎每个脚本的第一个参数都是它。

3. 开了多个嘉立创窗口时:

python tools/eda_bridge.py windows            # 列出已连接的窗口
python tools/eda_bridge.py select <windowId>  # 指定活动窗口

传 JS 一律用文件(run <文件>),不要用命令行字符串(exec "<字符串>")。 PowerShell 会破坏引号和 Ω 这类字符。

4. 离线验证,不需要嘉立创。 仓库自带一份四器件的演示网表,可以先把网表这一段跑通:

python tools/tel2json_netlist.py examples/demo.tel examples/out.json --bom examples/demo_bom.csv
python tools/netlist_drc.py examples/out.json

第一条会打印 器件 4 | 引脚 10 | 已配料号 4/4; 第二条会把 NC_SPARE 这个只连了一个引脚的网标出来,这正是它的用途。


选型调研

链路的起点在脚本之前:电路需求要先变成一份带真实供应商编号的 BOM。 这一段是调研而不是自动化,所以本仓库给的是提示词模板而不是代码—— 把模板交给任意一个具备联网检索能力的 AI,最后用一份核验清单收口。

模板不写任何 AI 品牌,不假设执行者了解你的项目,所有待填处用〈尖括号说明〉标出。 换一个模型接手,用法完全一样。

模板 用途
prompts/component-sourcing-brief.zh.md 选型调研任务书:你填需求规格(电气、封装、温度范围、成本上限、装配工艺约束、目标产线、供货),AI 产出主选与备选的逐项对照表
prompts/part-number-verification.zh.md 料号核验清单,在任何编号写进 BOM 之前跑

英文版:component-sourcing-brief.en.mdpart-number-verification.en.md。 阶段说明与交接约定见 docs/component-sourcing.zh.md

最要紧的一条纪律: 任何 C 编号,必须在器件库中实际检索命中之后才算数—— 检索确实返回了这个编号对应的器件、库存 > 0、封装与关键参数逐项对上。 元器件编号是语言模型会安静出错的一类内容:格式规整、长度固定, 很容易生成出一个格式完全正确但根本不存在、或者存在但对应完全不同器件的编号, 而这类错误在导入之前没有任何症状。

核验有两条通道:立创商城 / 嘉立创元件库网页检索, 或经桥直接查 EDA 客户端连着的那个库——examples/30_library_search.js 为此封装了 eda.lib_Device.search()eda.lib_Device.getByLcscIds(), 可读出库存、价格与基础库 / 扩展库归属。

为什么这一段属于本仓库: 后面每一个自动化步骤都假设 Supplier Part 是对的。 一旦不对,tel2json_netlist.py 会忠实地把错编号写进网表,导入会忠实地放上错器件, fix_supplier_ids.py 会忠实地把错编号刷得更一致。后面没有任何一步会告诉你编号本身错了。


主线流程:从网表到下单文件

完整版在 docs/netlist-import.zh.md,这里给骨架。

电路需求
        │  prompts/component-sourcing-brief.zh.md   (选型调研)
        │  prompts/part-number-verification.zh.md   (写进 BOM 之前核验)
        ▼
.tel 网表 + BOM(带已核验的立创料号)
        │  tel2json_netlist.py
        ▼
   带料号的网表 .json  ──── netlist_drc.py(离线自查)
        │  generate_schematic_from_json.py
        ▼
   原理图有器件了
        │  fix_supplier_ids.py / fix_nc.py
        ▼
   原理图 DRC 干净
        │  compare_netlist.py(逐脚校验导入忠实度)
        ▼
        │  sync_pcb_via_importchanges.py
        ▼
   PCB 上器件和飞线到位
        │  摆件 / 板框 / 布线(API 或 FreeRouting)
        ▼
        │  repour_safe → neck_analyze → gap_nudge → width_cut → neck_sink → fix_sink
        ▼
   DRC 收敛
        │  netcmp_live.py 逐脚回归 + render_at.py 截图确认
        ▼
        │  export_mfg.py
        ▼
   BOM + 贴片坐标,可以下单

命门一:料号

网表重建扩展查库只认 props["Supplier Part"],即立创 C 料号。 厂家型号与封装名不参与匹配。没料号导入直接失败;填错料号会静默放上错器件, 而且事后改不回来——modify 改不了器件的库关联,只能改 JSON 重新导入。 界面上的"器件标准化"也救不了,它只会标准化成那个错料号指向的器件。

因此 tel2json_netlist.py 用三级兜底匹配(精确位号 → 封装+数值 → 封装唯一), 配不上的列出告警而不是猜一个

命门二:addIntoPcb

sch_PrimitiveComponent.create(component, x, y, subPartName, rotation, mirror, addIntoBom, addIntoPcb)

最后两个参数(尤其 addIntoPcb)漏传,器件就只存在于原理图。 后续同步到 PCB 会放 0 个元件,而且没有任何报错解释原因。

命门三:那个要等几分钟的对话框

pcb_Document.importChanges(schUuid) 返回 true 不代表元件落板了,只代表弹出了一个确认对话框。 只有点了那个标着**「应用修改」**(不是「确定」)的按钮,元件才会真的放上去。

某些版本上这个对话框要好几分钟才渲染出来。15 秒或 40 秒的看门狗会报"对话框没出现", 从而让你得出"API 坏了"的错误结论。

sync_pcb_via_importchanges.py 默认等 300 秒,期间持续扫描按钮。 找不到按钮就跑 list_eda_buttons.ps1,把实际存在的按钮名打出来。

命门四:DRC 干净不等于板子连对了

实证:故意断开一条网,DRC 仍报 0 违例。 嘉立创的 DRC 管的是间距与孔的几何,不检查连通性

连通引擎只认完全重合的端点——线身交叠不算连接,T 形穿越不算连接,端点"非常接近"也不算。 坐标四舍五入到两位小数就是开路,而且没有任何提示。

每一轮几何操作之后都跑一遍 netcmp_live.py 做逐脚回归。

命门五:返回成功但没落盘的写入

有些 API 调用返回成功、当场读回是新值,重启之后仍是旧值。 已确认的有:过孔孔径/盘径、铺铜轮廓宽、以及传错形状的规则配置。

读回新值不算验证。改了关键属性之后,重启嘉立创再读一遍。


工具清单

全部在 tools/,扁平放置——脚本之间靠同目录相对路径互相调用,别拆开。

桥与界面

脚本 用途
eda_bridge.py 所有联机脚本的入口。找桥、查状态、提交 .js 作业。子命令:health / windows / select / run / exec
start_bridge.bat 启动官方桥并检查连接(先改里面的 SKILL_DIR
click_eda_confirm.ps1 用 UIAutomation 点「应用修改」。中文按钮名在脚本内由 Unicode 码点拼出,绕开所有编码层
list_eda_buttons.ps1 诊断:打印嘉立创所有窗口的所有按钮名。版本改了按钮文案时用它

网表 → 原理图

脚本 用途
tel2json_netlist.py .tel + BOM → 带料号的网表 JSON。三级匹配,配不上就告警而不是猜
netlist_drc.py 离线自查:单引脚网、重复位号、连接率。不需要开嘉立创
generate_schematic_from_json.py 经桥生成原理图:查库 → 放器件 → 改位号 → 每脚拉一段带 net 的短线
fix_supplier_ids.py 批量修正 SupplierId,消掉"供应商不符"的 DRC 项
fix_nc.py 批量给未用引脚打 NC 标记,消掉"引脚悬空"警告
compare_netlist.py 源网表与导出结果逐脚比对,校验导入忠实度
netcmp_live.py 读板上实况与 .tel 源比对。几何操作后的回归校验用它

原理图 → PCB

脚本 用途
sync_pcb_via_importchanges.py importChanges + 自动点「应用修改」+ 轮询到器件数稳定。对话框默认等 300 秒

PCB 几何

按这个顺序跑:

脚本 用途
repour_safe.py 安全重灌铺铜。发 Shift+B 之前先确认嘉立创确实是前台窗口,否则中止——按键绝不能落进别的程序
neck_analyze.py 违例台账:按网络、按网络对统计,看清是哪几条网在闹
gap_nudge.py 平移违例线段。只动几何不动拓扑;端点连同精确共享该端点的段一起动;挪之前先查空间
width_cut.py 把违例的过宽线段降到目标线宽。适用于那些多出来的宽度本来就是余量、并非载流需要的情况
neck_sink.py 把拥堵的干线段挪到内层,给表层腾净空。会改拓扑,动手前自动备份该网络
fix_sink.py 重定位那些离板框或其它孔太近的过孔
render_at.py 对关注点截图。改完自己看一眼,别只信 API 返回值

下单

脚本 用途
export_mfg.py 导出 BOM 与贴片坐标。处理两个坑:嘉立创的 "csv" 实为 UTF-16LE + TAB 分隔;文件内容经 base64 过桥以避开控制台编码

值得先读的坑

完整列表在 docs/pitfalls.zh.md。最贵的十条:

  1. 返回成功但没落盘的写入。 过孔孔径与铺铜轮廓宽都会报成功却没保存。重启嘉立创复核。
  2. DRC 不管连通性。 断了的网照样报 0。连通要独立校验。
  3. 连通要求端点完全重合。 坐标四舍五入就是开路,无任何提示。
  4. 共线同网的段在创建时会被合并。 想在干线中间保留一个接头,就把接头过孔在干线中心线上下各偏几 mil 交替放置,相邻段斜率不同就不会被合并。否则拆开的段会被粘回一条,接头落到线身上(见第 3 条)。
  5. 图元 id 出了作业边界就失效。 读 id 与用 id 必须在同一个桥作业内。跨作业使用会抛 t.isAsync is not a function,还可能让批量操作跑一半死掉——此前的改动已经落板,网络被撕成两半。
  6. DRC 会报幻影违例。 closeDocument 再打开就消失了。在断定某块板需要返工之前先复核。
  7. 中文 Windows 上的三个编码坑。 Python 打印非 GBK 字符会崩(用 sys.stdout.reconfigure); 读 PowerShell 输出必须显式指定 utf-8;嘉立创导出的 "csv" 是 UTF-16LE + TAB。 一个在打印成功信息时崩掉的脚本,看起来和真的失败一模一样。
  8. pcb_PrimitivePolyline.create(net, layer, polygon, lineWidth, primitiveLock)——net 在第一位, polygon 必须用 pcb_MathPolygon.createPolygon([...]) 工厂构造,直接传裸数组会报参数错误。
  9. 单个作业约 30 秒上限。 据此分批:属性 modify 约 40 个一批,几何 modify 约 150 个一批。
  10. 在断定一块板不可用之前,先做三件事:逐路核算电流、清掉幻影违例后复核、 区分电气问题、制造性问题与规则问题。制造性问题(线宽低于板厂下限、孔径低于最小钻孔) 靠局部调整解决,不是推倒重来。

目录结构

easyeda-agent-toolkit/
├── README.md                 本文(英文在前,中文在后)
├── LICENSE                   MIT
├── docs/                     指南, 中英双语
│   ├── component-sourcing.{en,zh}.md   选型阶段与交接约定
│   ├── netlist-import.{en,zh}.md       网表到 PCB 的完整流程
│   └── pitfalls.{en,zh}.md             API 行为与坑
├── prompts/                  AI 无关提示词模板, 中英双语
│   ├── component-sourcing-brief.{en,zh}.md
│   └── part-number-verification.{en,zh}.md
├── tools/                    脚本(扁平放置,互相靠相对路径调用)
│   └── eda_jobs/             脚本生成的临时 JS 作业落在这里(不入 git)
└── examples/
    ├── 00_probe.js            连通性探针与列板
    ├── 10_export_netlist.js   导出成品网表落盘
    ├── 20_pin_truth_probe.js  脚位探针(比 datasheet 可靠)
    ├── 30_library_search.js   器件库检索与料号核验
    ├── demo.tel               演示网表,四个器件,可直接跑
    ├── demo_bom.csv           配套 BOM
    └── example_netlist.json   该演示的产物,也是网表 JSON 的格式参考

examples/ 下的料号与网名都是占位值,不对应任何真实设计。


声明

本项目是非官方项目,与嘉立创(JLC / LCEDA / 立创EDA)没有任何关联,也未获得其认可。 涉及的产品名与商标仅用于说明兼容性。

关于官方 skill。 本仓库依赖 easyeda/easyeda-api-skill(JLCEDA,MIT 协议) 提供的桥服务与 API 参考,但不包含、不复制、不重新分发它的任何内容。 请按环境准备自行安装,其版权归 JLCEDA 所有。

关于作者。 这些脚本由 Claude(Anthropic)与作者协作产出。本仓库以 MIT 协议发布。

风险自负。 这些脚本会直接修改你的嘉立创工程文件,其中几个 (neck_sink.pyfix_sink.pywidth_cut.pygap_nudge.py)会成批改动板上几何。 请先备份工程。 作者不对使用本工具箱造成的设计损失、生产损失或费用承担责任。 具体行为——按钮文案、API 签名、DRC 返回结构——会随嘉立创版本变化,请先在废板上试。

关于数据。 本仓库不含任何凭据、API token 或私有板卡数据——没有网表、坐标、料号、网络名或 Gerber。 examples/ 下的内容全部是编造的。

About

嘉立创EDA专业版 × AI 编码代理的自动化画板工具箱与实战教程(基于官方 easyeda-api-skill 桥)

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages