Home > PCB_PrimitiveComponent > getAllPinsByPrimitiveId
PCB_PrimitiveComponent.getAllPinsByPrimitiveId() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Get all pads associated with the device
Signature
typescript
function getAllPinsByPrimitiveId(
primitiveId: string,
): Promise<Array<IPCB_PrimitiveComponentPad> | undefined>;1
2
3
2
3
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveId | string | Device primitive ID |
Returns
Promise<Array<IPCB_PrimitiveComponentPad> | undefined>
Device pad primitive array
Example
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