Home > IPCB_PrimitiveArc > getAdjacentPrimitives
IPCB_PrimitiveArc.getAdjacentPrimitives() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
获取相邻的图元对象
签名
typescript
function getAdjacentPrimitives(): Promise<
Array<IPCB_PrimitiveLine | IPCB_PrimitiveVia | IPCB_PrimitiveArc>
>;1
2
3
2
3
返回值
Promise<Array<IPCB_PrimitiveLine | IPCB_PrimitiveVia | IPCB_PrimitiveArc>>
相邻的直线、过孔、圆弧线图元对象
备注
将会获取与圆弧线直接相连的直线、过孔、圆弧线图元对象
示例
javascript
// 1. 创建一条直线走线,终点落在 (7500, 7000)
const line = await eda.pcb_PrimitiveLine.create('', 1, 7000, 7000, 7500, 7000, 10);
// 2. 创建一段圆弧,起点与直线终点重合,两段构成一整段导线
const arc = await eda.pcb_PrimitiveArc.create('', 1, 7500, 7000, 7800, 7300, 90, 10, 1, false);
// 3. 获取与圆弧直接相连的图元,并读出各自的类型
const adjacent = await arc.getAdjacentPrimitives();
// 4. 清理测试图元(查询类案例不留测试对象)
await eda.pcb_PrimitiveLine.delete([line]);
await eda.pcb_PrimitiveArc.delete([arc]);
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17