Skip to content

easyeda/easyeda-api-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easyeda-api-skill

嘉立创EDA专业版 AI Skill — 让AI直接操控嘉立创EDA。EasyEDA Pro AI Skill - Enable AI to directly control EasyEDA.

Version License Node.js


📑 目录 / Table of Contents


🇨🇳 中文

嘉立创EDA专业版AI SKILL,为AI编程工具提供完整的EasyEDA Pro API接口和WebSocket桥接能力。

✨ 特性

  • 📚 完整API参考 — 120+ 类、62+ 枚举、70+ 接口、19+ 类型别名
  • 🔌 WebSocket桥接 — 在运行的EasyEDA Pro客户端中执行代码
  • 🛠️ 代码模式 — PCB、原理图、库、项目管理的常用操作
  • 🌐 多窗口支持 — 同时连接多个EasyEDA窗口
  • 🔍 自动端口发现 — 自动扫描并连接可用端口(49620-49629)

📦 安装

方法一:直接下载

  1. 下载本仓库并解压
  2. 放入AI编程工具的SKILL目录

方法二:Git克隆

git clone https://github.com/easyeda/easyeda-api-skill.git
cd easyeda-api-skill
npm install

🚀 快速开始

1. 启动桥接服务

cd easyeda-api-skill
npm run server

桥接服务将在端口范围 49620-49629 中自动选择可用端口启动。

2. 安装EasyEDA扩展

在EasyEDA Pro中安装 run-api-gateway.eext 扩展:

👉 下载扩展

扩展加载后将自动连接桥接服务。

3. 验证连接

# 检查桥接服务状态
curl http://localhost:49620/health

# 查看已连接的EDA窗口
curl http://localhost:49620/eda-windows

4. 执行代码

curl -X POST http://localhost:49620/execute \
  -H "Content-Type: application/json" \
  -d '{"code": "return await eda.dmt_Project.getCurrentProjectInfo();"}'

🏗️ 架构

┌──────────┐   HTTP/WS     ┌────────────────┐   WebSocket    ┌──────────┐
│ AI Agent  │ ◄───────────► │  Bridge Server  │ ◄───────────► │  EasyEDA  │
│           │  Port Range   │  (Node.js)      │  Port Range   │  (Client) │
└──────────┘  49620-49629   └────────────────┘  49620-49629   └──────────┘

📖 文档

API参考

完整的API文档位于 references/ 目录:

  • 📑 API索引 — 所有类、枚举、接口的完整列表
  • ⚡ 快速参考 — 所有方法签名快速查找
  • 📁 类文档 — 120个类的详细文档
    • DMT_* — 文档管理 (Board, Project, Schematic, Pcb...)
    • PCB_* — PCB与封装操作
    • SCH_* — 原理图操作
    • LIB_* — 库管理 (Symbol, Footprint, Device...)
    • SYS_* — 系统功能 (Dialog, FileSystem, Message...)
  • 📁 枚举文档 — 62个枚举
  • 📁 接口文档 — 70个接口定义
  • 📁 类型文档 — 19个类型别名

开发指南

用户指南

💡 使用示例

项目操作

// 获取当前项目信息
return await eda.dmt_Project.getCurrentProjectInfo();

// 列出所有电路板
return await eda.dmt_Board.getAllBoardsInfo();

// 创建新电路板
return await eda.dmt_Board.createBoard();

PCB操作

// 在铜膜层创建导线
await eda.pcb_PrimitiveLine.create(
  "GND",   // 网络
  1,       // 层 (顶层铜膜)
  0,       // 起点X (单位: 1mil)
  0,       // 起点Y
  1000,    // 终点X
  0,       // 终点Y
  10,      // 线宽
  false    // 是否锁定
);

// 修改图元 (异步模式)
const prim = await eda.pcb_PrimitiveComponent.get([id]);
const asyncPrim = prim.toAsync();
asyncPrim.setState_X(newX);
asyncPrim.setState_Y(newY);
asyncPrim.done();

原理图操作

// 获取所有页面
return await eda.dmt_Schematic.getAllSchematicDocumentsInfo();

// 创建元件
await eda.sch_PrimitiveComponent.create(
  "device-uuid",  // 元件UUID
  5000,           // X坐标 (单位: 0.01inch)
  5000,           // Y坐标
  "",             // 子部件名称
  0,              // 旋转角度
  false,          // 镜像
  true,           // 加入BOM
  true            // 加入PCB
);

系统功能

// 显示提示消息
eda.sys_Message.showToastMessage("操作完成!");

// 显示确认对话框
const confirmed = await eda.sys_Dialog.showConfirmationMessage("确认继续?");

// 运行DRC检查
const passed = await eda.pcb_Drc.check(true, true, false);

⚠️ 重要提示

坐标单位

不同域使用不同的坐标单位:

单位 换算
PCB 1mil 1mm ≈ 39.37 units
原理图 0.01inch (10mil) 1mm ≈ 3.937 units

这是AI最常犯的错误! 单位错误会导致元件放置位置偏差10倍。

文档状态

操作前必须验证:

  1. ✅ 项目已打开 — 使用 eda.dmt_Project.getCurrentProjectInfo() 验证
  2. ✅ 文档类型匹配 — PCB API需要活动PCB文档,SCH API需要活动原理图文档
  3. ✅ 正确的文档已激活 — 使用 eda.dmt_SelectControl.getCurrentDocumentInfo() 检查

产品名称

  • 中文名:嘉立创EDA
  • 英文名:EasyEDA

🔌 相关项目


🇬🇧 English

EasyEDA Pro AI Skill for AI programming tools, providing complete API reference and WebSocket bridge capabilities.

✨ Features

  • 📚 Complete API Reference — 120+ classes, 62+ enums, 70+ interfaces, 19+ type aliases
  • 🔌 WebSocket Bridge — Execute code in the running EasyEDA Pro client
  • 🛠️ Code Patterns — Common operations for PCB, schematic, library, and project management
  • 🌐 Multi-Window Support — Connect multiple EasyEDA windows simultaneously
  • 🔍 Auto Port Discovery — Automatically scan and connect to available ports (49620-49629)

📦 Installation

Method 1: Direct Download

  1. Download this repository and extract
  2. Place it in your AI programming tool's SKILL directory

Method 2: Git Clone

git clone https://github.com/easyeda/easyeda-api-skill.git
cd easyeda-api-skill
npm install

🚀 Quick Start

1. Start Bridge Server

cd easyeda-api-skill
npm run server

The bridge server will automatically start on an available port in the range 49620-49629.

2. Install EasyEDA Extension

Install the run-api-gateway.eext extension in EasyEDA Pro:

👉 Download Extension

The extension will automatically connect to the bridge service after loading.

3. Verify Connection

# Check bridge service status
curl http://localhost:49620/health

# List connected EDA windows
curl http://localhost:49620/eda-windows

4. Execute Code

curl -X POST http://localhost:49620/execute \
  -H "Content-Type: application/json" \
  -d '{"code": "return await eda.dmt_Project.getCurrentProjectInfo();"}'

🏗️ Architecture

┌──────────┐   HTTP/WS     ┌────────────────┐   WebSocket    ┌──────────┐
│ AI Agent  │ ◄───────────► │  Bridge Server  │ ◄───────────► │  EasyEDA  │
│           │  Port Range   │  (Node.js)      │  Port Range   │  (Client) │
└──────────┘  49620-49629   └────────────────┘  49620-49629   └──────────┘

📖 Documentation

API Reference

Complete API documentation is located in the references/ directory:

  • 📑 API Index — Complete list of all classes, enums, and interfaces
  • ⚡ Quick Reference — Quick lookup for all method signatures
  • 📁 Class Docs — Detailed documentation for 120 classes
    • DMT_* — Document Management (Board, Project, Schematic, Pcb...)
    • PCB_* — PCB & Footprint Operations
    • SCH_* — Schematic Operations
    • LIB_* — Library Management (Symbol, Footprint, Device...)
    • SYS_* — System Functions (Dialog, FileSystem, Message...)
  • 📁 Enum Docs — 62 enums
  • 📁 Interface Docs — 70 interface definitions
  • 📁 Type Docs — 19 type aliases

Development Guide

User Guide

💡 Usage Examples

Project Operations

// Get current project info
return await eda.dmt_Project.getCurrentProjectInfo();

// List all boards
return await eda.dmt_Board.getAllBoardsInfo();

// Create a new board
return await eda.dmt_Board.createBoard();

PCB Operations

// Create a trace on copper layer
await eda.pcb_PrimitiveLine.create(
  "GND",   // net
  1,       // layer (top copper)
  0,       // startX (unit: 1mil)
  0,       // startY
  1000,    // endX
  0,       // endY
  10,      // lineWidth
  false    // primitiveLock
);

// Modify primitive (async mode)
const prim = await eda.pcb_PrimitiveComponent.get([id]);
const asyncPrim = prim.toAsync();
asyncPrim.setState_X(newX);
asyncPrim.setState_Y(newY);
asyncPrim.done();

Schematic Operations

// Get all pages
return await eda.dmt_Schematic.getAllSchematicDocumentsInfo();

// Create a component
await eda.sch_PrimitiveComponent.create(
  "device-uuid",  // component UUID
  5000,           // X coordinate (unit: 0.01inch)
  5000,           // Y coordinate
  "",             // subPartName
  0,              // rotation
  false,          // mirror
  true,           // addIntoBom
  true            // addIntoPcb
);

System Functions

// Show toast message
eda.sys_Message.showToastMessage("Operation complete!");

// Show confirmation dialog
const confirmed = await eda.sys_Dialog.showConfirmationMessage("Proceed?");

// Run DRC check
const passed = await eda.pcb_Drc.check(true, true, false);

⚠️ Important Notes

Coordinate Units

Different domains use different coordinate units:

Domain Unit Conversion
PCB 1mil 1mm ≈ 39.37 units
Schematic 0.01inch (10mil) 1mm ≈ 3.937 units

This is the most common mistake made by AI! Unit errors will cause components to be placed 10x off position.

Document State

Must verify before operations:

  1. ✅ Project is opened — Use eda.dmt_Project.getCurrentProjectInfo() to verify
  2. ✅ Document type matches — PCB APIs require active PCB document, SCH APIs require active Schematic document
  3. ✅ Correct document is active — Use eda.dmt_SelectControl.getCurrentDocumentInfo() to check

Product Naming

  • Chinese: 嘉立创EDA
  • English: EasyEDA

🔌 Related Projects


Version: 1.0.3
Author: JLCEDA
Compatibility: Node.js 18+, EasyEDA Pro desktop client (extension support required)

About

嘉立创EDA专业版AI SKILL,为AI编程工具提供完整的EasyEDA Pro API接口和WebSocket桥接能力。EasyEDA Pro AI SKILL provides a complete EasyEDA Pro API interface and WebSocket bridging capability for AI programming tools.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors