easyeda / easyeda/pro-api-sdk

开放「组合 / 多通道复用(Reuse Block / Group ID / Channel ID)」的读写 API

Open
#35 0 comments 0 reactions 0 assignees View on GitHub
enhancement seems like AI
Dominant language
TypeScript
Stars
64
Forks
26
PR merge metrics
No merged PRs in 30d

Description

## 背景 / Context

EasyEDA Pro 元件属性面板「更多属性」下有真实存在的 **`Reuse Block`(复用块)/
`Group ID`(分组 ID)/ `Channel ID`(通道 ID)** 字段(左侧对象面板还有「组合」树视图),
是官方多通道设计 / 模块复用(CBB)体系的一部分。用扩展做原理图自动化时,我们需要:
读出一个已放置器件属于哪个组 / 通道,在批量移动 / 重排时保留它,以及程序化地
把「一个主控 + 外围电路」编成一组。

但这套成员归属对扩展 API **完全不可见,也不可写**。

## 复现 / Repro(`eda.sch_PrimitiveComponent`,3.2.148)

```js
const c = (await eda.sch_PrimitiveComponent.getAll())
.find(x => x.getState_ComponentType?.() === 'part');
const id = c.getState_PrimitiveId();
const dev = c.getState_Component().uuid;

// —— 读:三条路径全空 / 全失败 ——
c.getState_OtherProperty(); // 只有 BOM/规格字段,无 Group/Channel ID
await eda.sch_PrimitiveComponent.getComponentDetail(id); // ❌ Error: 获取器件详情失败
await eda.sch_PrimitiveComponent.getComponentDetail(dev); // ❌ 同上
await eda.sch_PrimitiveComponent.getComponentDetail({ primitiveId: id }); // ❌ 同上
await eda.sch_PrimitiveComponent.getAllPropertyNames(); // 含 "Group ID"/"Channel ID"/"Reuse Block"
// —— 但这是 schema 名单,不是该器件的值

// —— 写:静默丢弃 ——
await eda.sch_PrimitiveComponent.modify(id, { otherProperty: { 'Channel ID': 'CH1' } });
// 返回对象里 otherProperty 无 'Channel ID' 键;重新 getAll 读回也无变化(写被忽略)

// —— 成员关系:lib_Cbb 只管「库」,不是当前图纸的成员归属 ——
await eda.lib_Cbb.search(''); // [] —— 复用块库检索,读不到某器件属于哪个通道
```

**类型定义佐证(`@jlceda/pro-api-types/index.d.ts`)**:
- `getComponentDetail` 被声明为 **`private getComponentDetail;`**(两处)——它是**私有方法**,
不在公开 API 面,故扩展调用必然「获取器件详情失败」。器件详情(很可能含组/通道)
在内部是有的,只是没开放。
- 全文**无** `Channel ID`/`Group ID`/`Reuse Block` 作为可读字段,**无** `getState_Channel/Group/Reuse`。
- `LIB_Cbb` 全部方法只接受 `cbbUuid`+`libraryUuid`(复用块**库**管理),不涉及某张
图纸上已放置器件的组/通道成员归属。

现象汇总:

| 能力 | 尝试的 API | 结果 |
|---|---|---|
| 读单个器件的 Group/Channel/Reuse | `getState_OtherProperty()` | 不含这些字段 |
| | `getComponentDetail(id / deviceUuid / {})` | 全部抛「获取器件详情失败」 |
| | `getAllPropertyNames()` | 返回属性**名**(含三者),但无**值** |
| 写 Group/Channel/Reuse | `modify({otherProperty:{'Channel ID':…}})` | 静默丢弃 |
| 查成员归属 | `lib_Cbb.get/search` | 只检索复用块库,非图纸成员关系 |
| 任何专用 getter/setter | `sch_PrimitiveComponent` / `pcb_PrimitiveComponent` | 零个 group/channel 方法 |

## 挡住了什么 / Impact

1. **批量移动会丢组**:任何删除+重建图元的自动化(整体挪一个模块的导线)会让
重建的图元掉出原生组;而我们无法读组、也无法恢复组,只能眼睁睁看它散掉。
2. **无法程序化编组**:做不到「放完一个主控+外围后自动编成一组」。
3. **无法控制是否透传 PCB**:`Channel ID`/`Reuse Block` 是多通道系统、会驱动 PCB
通道复制;但扩展既读不到也管不了,用户容易在只想要「原理图布局便利」时误带
多通道语义进 PCB,而自动化无从检测或规避。

## 请求 / Ask

给已放置器件的组 / 通道成员归属一条读写通道,任选其一即可:

- **读**:修复 `getComponentDetail`(让它对已放置 primitiveId 正常返回,且结果里
含 `Reuse Block`/`Group ID`/`Channel ID`);或在 `getState_OtherProperty()` 里
纳入这三个字段;或新增 `getState_GroupId()` / `getState_ChannelId()` / `getState_ReuseBlock()`。
- **写**:让 `modify` 接受这三个字段;或新增对应 setter。
- **成员枚举**(可选加分):一个「按 Group/Channel ID 列出同组 primitiveId」的方法,
等价于左侧「组合」树视图的数据。

有了读即可解 #1/#3(保留 + 检测透传),有了写即可解 #2(程序化编组)。

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by inspecting @jlceda/pro-api-types/index.d.ts and the sch_PrimitiveComponent declarations, especially getComponentDetail, getState_OtherProperty, and modify. Compare these with the lib_Cbb methods and determine an appropriate public read/write path for placed components; done means Group ID, Channel ID, and Reuse Block membership can be read and written through the documented API.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.