Home > IPCB_PrimitiveVia > getAdjacentPrimitives
IPCB_PrimitiveVia.getAdjacentPrimitives() 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 Adjacent primitive objects
Signature
typescript
function getAdjacentPrimitives(): Promise<Array<IPCB_PrimitiveLine | IPCB_PrimitiveArc>>;1
Returns
Promise<Array<IPCB_PrimitiveLine | IPCB_PrimitiveArc>>
Adjacent wire and arc-line primitive objects
Remarks
It will get the wire and arc-line primitive objects directly connected to the via
Example
javascript
// 1. 生成本次运行专用的坐标,放置一个测试过孔
const x = 3000 + Math.floor(Math.random() * 100000);
const via = await eda.pcb_PrimitiveVia.create('', x, 3000, 20, 40);
// 2. 在过孔两侧各拉一条顶层导线,端点落在过孔中心构成连接
const line1 = await eda.pcb_PrimitiveLine.create('', 1, x - 600, 3000, x, 3000, 10);
const line2 = await eda.pcb_PrimitiveLine.create('', 1, x, 3000, x + 600, 3000, 10);
// 3. 获取与过孔直接相连的图元,并读出各自的类型
const adjacent = await via.getAdjacentPrimitives();
// 4. 清理测试图元(查询类案例不留测试对象)
await eda.pcb_PrimitiveVia.delete([via.getState_PrimitiveId()]);
await eda.pcb_PrimitiveLine.delete([line1.getState_PrimitiveId(), line2.getState_PrimitiveId()]);
console.log('adjacent count:', adjacent.length);
adjacent.forEach((p, i) => {
console.log(`adjacent[${i}] type:`, p.getState_PrimitiveType());
});1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19