欢迎光临
我们一直在努力

AI Agent辅助立创EDA设计——从原理图到PCB



AI Agent + 立创EDA Pro 集成全方案

AI Agent 如何操控立创EDA Pro 绘制原理图与PCB?本文梳理全部5种方案,从轻量脚本到生产级 CLI,附完整教程。

核心认知:立创EDA Pro 提供完整的 扩展 API(eda.* 对象),通过 TypeScript 扩展可直接操控原理图/PCB/元件库/DRC。AI Agent 与 EDA 的集成,本质上是搭建"AI 决策 → 动作命令 → EDA 执行"的桥梁。

一、五种集成方案总览

方案通信方式复杂度实时性生产就绪适合场景
方案一:easyeda-agent WebSocket ⭐ 低 ✅ ✅ 主力工作流、生产环境
方案二:官方 API Gateway WebSocket ⭐⭐ 低 ✅ ✅ 官方推荐、99%功能覆盖
方案三:自定义扩展+文件桥 JSON 文件 ⭐⭐ 中 ❌ ⚠️ 快速原型、无网络环境
方案四:自定义扩展+HTTP桥 HTTP REST ⭐⭐⭐ 中 ✅ ⚠️ 实时双向交互
方案五:直接脚本执行 无(手动粘贴) ⭐ 低 ❌ ❌ 单次验证、学习测试

二、方案一:easyeda-agent(Daboluo 项目)⭐⭐⭐⭐⭐

概述

由开发者 Daboluo 打造的开源项目,将 20 个审核过的类型化动作封装为 Go CLI,通过 WebSocket 连接 LCEDA 内的 .eext 连接器插件。

架构:

Skill 描述工作流 → Go CLI/Daemon (49620-49629) → WebSocket → .eext Connector → eda.* API

完整教程

Step 1:安装

curl -fsSL https://raw.githubusercontent.com/zhoushoujianwork/easyeda-agent/main/install.sh | sh

Step 2:导入连接器插件
从 GitHub Release 下载 .eext → LCEDA Pro → 设置 → 扩展 → 安装本地扩展

Step 3:启动守护进程

easyeda daemon

Step 4:验证连接

easyeda health
# → daemon: online, connector: connected

Step 5:AI 控制(Hermes 集成示例)

# 搜索器件
easyeda sch search –keyword "STM32H753"

# 放置芯片
easyeda sch place –lib-uuid xxx –designator U1 –x 3000 –y 3000

# 单步连引脚出网络标
easyeda sch connect-pin –designator U1 –pin PA9 –net "USART1_TX"

# 创建电源/地标
easyeda sch power-flag –net "VDD_3V3"
easyeda sch ground-flag –net "GND"

# DRC 检查
easyeda sch drc

# 导出
easyeda sch export netlist
easyeda sch export bom –format xlsx


三、方案二:官方 eext-run-api-gateway ⭐⭐⭐⭐

概述

立创EDA官方提供的 WebSocket API 网关扩展,在扩展广场直接安装。外部 AI 编程工具通过 WebSocket 协议调用 LCEDA 99% 功能。

架构:

AI 编程工具 (Cursor/Claude Code/Hermes) ← WebSocket → eext-run-api-gateway → LCEDA 编辑器

完整教程

Step 1:安装网关扩展
LCEDA Pro → 扩展 → 扩展广场 → 搜索 “eext-run-api-gateway” → 安装

Step 2:获取网关端口(通常为 9527 或类似)

Step 3:Python 客户端示例

import asyncio, websockets, json

async def lceda(action, params={}):
async with websockets.connect("ws://localhost:9527") as ws:
await ws.send(json.dumps({"action": action, "params": params}))
return json.loads(await ws.recv())

# 放置元件
result = await lceda("place_component", {
"lcsc": "C17577866", "designator": "U1", "x": 1000, "y": 2000
})

# DRC 检查
result = await lceda("run_drc", {"type": "sch"})

# 导出 BOM
bom = await lceda("export_bom", {"format": "csv"})


四、方案三:自定义扩展 + 文件桥接 ⭐⭐⭐

概述

最传统的集成方式。Hermes Agent 将网表写入 JSON 文件,LCEDA 扩展轮询读取后执行。

架构:

Hermes → 写入 /home/ros2/lceda-bridge/netlist-input.json
← 读取 /home/ros2/lceda-bridge/draw-result.json ← LCEDA 扩展写入

完整教程

① 搭建 SDK

git clone –depth=1 https://gitee.com/jlceda/pro-api-sdk.git
cd pro-api-sdk && npm install

② LCEDA 扩展代码 src/index.ts

import { eda } from '@jlceda/pro-api-types';
import * as fs from 'fs';
import * as path from 'path';

const BRIDGE = '/home/ros2/lceda-bridge';

export async function drawFromAI() {
const f = path.join(BRIDGE, 'netlist-input.json');
if (!fs.existsSync(f)) return;

const { components, nets, netFlags } = JSON.parse(fs.readFileSync(f, 'utf-8'));
const uuids: string[] = [];

// ⚠️ 必须串行 await,不能 Promise.all
for (const comp of components) {
const c = eda.sch_PrimitiveComponent.create();
c.setSupplierId(comp.lcsc);
c.setDesignator(comp.designator);
c.setX(comp.x || 1000);
c.setY(comp.y || 2000);
c.setDeviceType(comp.deviceType);
await c.done();
uuids.push(c.getUuid());
}

// 自动布局
const typeMap = Object.fromEntries(components.map(c => [c.designator, c.deviceType]));
await eda.sch_Document.autoLayout({ uuids, netlist: { components, nets }, designatorDeviceTypeMap: typeMap });

// 保存
await eda.sch_Document.save();

// 写回结果
fs.writeFileSync(path.join(BRIDGE, 'draw-result.json'),
JSON.stringify({ status: 'ok', count: uuids.length }));
}

③ Hermes 端生成网表

import json

netlist = {
"components": [
{"lcsc": "C17577866", "designator": "U1", "deviceType": "chip", "x": 3000, "y": 3000},
{"lcsc": "C15849", "designator": "C1", "deviceType": "capacitor", "x": 5000, "y": 3000},
],
"nets": [],
"netFlags": [{"type": "ground", "netName": "GND"}]
}

with open('/home/ros2/lceda-bridge/netlist-input.json', 'w') as f:
json.dump(netlist, f, indent=2)


五、方案四:自定义扩展 + HTTP 桥接 ⭐⭐⭐

概述

LCEDA 扩展内启动 HTTP 服务或从扩展 fetch 到外部 HTTP 服务。适合实时双向场景。

架构:

Hermes HTTP Server (8765) ← HTTP → LCEDA 扩展 (fetch API)

完整教程

LCEDA 扩展端:

export async function drawViaHTTP() {
const resp = await fetch('http://localhost:8765/api/netlist');
const { components } = await resp.json();

for (const comp of components) {
const c = eda.sch_PrimitiveComponent.create();
c.setSupplierId(comp.lcsc);
c.setDesignator(comp.designator);
c.setX(comp.x); c.setY(comp.y);
c.setDeviceType(comp.deviceType);
await c.done();
}

await eda.sch_Document.save();

await fetch('http://localhost:8765/api/callback', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({status: 'ok'})
});
}

Hermes 端 Flask 服务:

from flask import Flask, jsonify, request
app = Flask(__name__)

@app.route('/api/netlist')
def netlist():
return jsonify({"components": [...]})

@app.route('/api/callback', methods=['POST'])
def callback():
data = request.json
print(f"LCEDA done: {data}")
return jsonify({"ok": True})

app.run(port=8765)


六、方案五:直接脚本执行 ⭐⭐

概述

不写扩展,直接在 LCEDA Pro 的高级 → 运行脚本中粘贴 JS 代码执行。

示例

(async function() {
const u1 = eda.sch_PrimitiveComponent.create();
u1.setSupplierId("C17577866"); // STM32H753
u1.setDesignator("U1");
u1.setX(3000); u1.setY(3000);
u1.setDeviceType("chip");
await u1.done();

const c1 = eda.sch_PrimitiveComponent.create();
c1.setSupplierId("C15849"); // 100nF 电容
c1.setDesignator("C1");
c1.setX(5000); u1.setY(3000);
c1.setDeviceType("capacitor");
await c1.done();

console.log('✅ Done');
})();


七、AI 语义检查(跨方案通用)

无论哪种方案,都可以通过收集设计上下文发给 AI 做语义检查——这是官方 DRC 做不到的:

检查项示例规则
VCAP 引脚 每个 VCAP 接 2.2μF 电容到地,容值偏差 ±20%
去耦电容 每个 VDD 附近 ≥1 个 100nF,距离 <500mil
晶振负载 负载电容匹配晶振规格
悬空输入 未连接输入引脚检测
CAN 终端 总线两端各 120Ω
USB 差分 90Ω 差分阻抗,P/N 等长
DDR 等长 数据线 ±25mil

八、方案选择建议

依据场景 → 选择方案

• 要最快出结果 → 方案五(直接脚本)
• 要和 Hermes 深度集成 → 方案三(文件桥接)
• 要实时交互调试 → 方案四(HTTP 桥接)
• 要官方推荐方案 → 方案二(API Gateway)
• 要生产级长期使用 → 方案一(easyeda-agent)⭐⭐⭐⭐⭐

相关页面

参考官方文档:
https://easyeda-agent.daboluo.cc/

赞(0)
未经允许不得转载:171主机测评 » AI Agent辅助立创EDA设计——从原理图到PCB
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址