Home > IPCB_PrimitiveComponentPad > getConnectedPrimitives
IPCB_PrimitiveComponentPad.getConnectedPrimitives() 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 connected primitives
Signature
typescript
function getConnectedPrimitives(
onlyCentreConnection: true,
): Promise<Array<IPCB_PrimitiveLine | IPCB_PrimitiveArc | IPCB_PrimitiveVia>>;1
2
3
2
3
Parameters
Parameter | Type | Description |
|---|---|---|
onlyCentreConnection | true | Whether to only use center connection. If it is |
Returns
Promise<Array<IPCB_PrimitiveLine | IPCB_PrimitiveArc | IPCB_PrimitiveVia>>
Remarks
This API can get the primitives that are in direct contact with the pad
Example
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();
const pin = (await comp.getAllPins())[0];
const padX = pin.getState_X();
const padY = pin.getState_Y();
// 2. 从焊盘中心拉一段走线(起点正好落在中心 → 属于中心连接)
const line = await eda.pcb_PrimitiveLine.create('', 1, padX, padY, padX + 600, padY, 10);
const lineId = line.getState_PrimitiveId();
// 3. 只查中心连接的图元
const centreConnected = await pin.getConnectedPrimitives(true);
// 4. 查所有接触的图元
const allConnected = await pin.getConnectedPrimitives(false);
// 5. 清理测试图元
await eda.pcb_PrimitiveLine.delete([lineId]);
await eda.pcb_PrimitiveComponent.delete([compId]);
console.log('centreConnectedCount:', centreConnected.length);
console.log('centreContainsLine:', centreConnected.some(p => p.getState_PrimitiveId() === lineId));
console.log('allConnectedCount:', allConnected.length);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25