Home > PCB_PrimitiveComponent > getAllPinsByPrimitiveId
PCB_PrimitiveComponent.getAllPinsByPrimitiveId() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
获取器件关联的所有焊盘
签名
typescript
function getAllPinsByPrimitiveId(
primitiveId: string,
): Promise<Array<IPCB_PrimitiveComponentPad> | undefined>;1
2
3
2
3
参数名
参数 | 类型 | 描述 |
|---|---|---|
primitiveId | string | 器件图元 ID |
返回值
Promise<Array<IPCB_PrimitiveComponentPad> | undefined>
器件焊盘图元数组
示例
javascript
// 1. 放置一个测试器件:
// 按立创编号从系统库精确反查器件,返回项不含 libraryUuid,需补上才能用于 create
const devices = await eda.lib_Device.searchByProperties({ supplierId: 'C1523' }, undefined, undefined, undefined, 5, 1);
const sysLibUuid = await eda.lib_LibrariesList.getSystemLibraryUuid();
const comp = await eda.pcb_PrimitiveComponent.create({ libraryUuid: sysLibUuid, uuid: devices[0].uuid }, 1, 5000, 5000);
const compId = comp.getState_PrimitiveId();
// 2. 取出该器件的全部焊盘图元对象
const pins = await eda.pcb_PrimitiveComponent.getAllPinsByPrimitiveId(compId);
// 3. 读取每个焊盘的归属与坐标,确认都属于该器件
const parentIds = pins.map(pin => pin.getState_ParentComponentPrimitiveId());
// 4. 清理测试器件(焊盘随器件一起删除)
await eda.pcb_PrimitiveComponent.delete([compId]);
console.log('pinCount:', pins.length);
console.log('allBelongToComponent:', parentIds.every(id => id === compId));
console.log('firstPin:', 'x:', pins[0].getState_X(), 'y:', pins[0].getState_Y());
console.log('firstPinParentId:', parentIds[0]);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