Home > IPCB_PrimitiveComponent > getAllPins
IPCB_PrimitiveComponent.getAllPins() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
获取器件关联的所有焊盘
签名
typescript
function getAllPins(): Promise<Array<IPCB_PrimitiveComponentPad>>;1
返回值
Promise<Array<IPCB_PrimitiveComponentPad>>
器件焊盘图元数组
示例
javascript
// 1. 放置一个测试器件
const devices = await eda.lib_Device.search('C0402');
const comp = await eda.pcb_PrimitiveComponent.create(devices[0], 1, 5000, 5000);
const compId = comp.getState_PrimitiveId();
// 2. 获取器件关联的所有焊盘图元
const pins = await comp.getAllPins();
// 3. 逐个读取焊盘的归属器件和图元 ID
const pinInfos = pins.map(pin => ({
parentMatch: pin.getState_ParentComponentPrimitiveId() === compId,
primitiveId: pin.getState_PrimitiveId(),
}));
// 4. 清理测试器件
await eda.pcb_PrimitiveComponent.delete([compId]);
console.log('pinCount:', pins.length);
console.log('allBelongToComponent:', pinInfos.every(p => p.parentMatch));
console.log('firstPinPrimitiveId:', pinInfos[0].primitiveId);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20