Home > PCB_Primitive > getPrimitiveBoardLine
PCB_Primitive.getPrimitiveBoardLine() 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 the board line of the primitive
Signature
typescript
function getPrimitiveBoardLine(
primitiveId: string,
layers?: Array<EPCB_LayerId>,
): Promise<IPCB_ComplexPolygon | undefined>;1
2
3
4
2
3
4
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveId | string | Primitive ID |
layers | Array<EPCB_LayerId> | (Optional) Layers to calculate. When calculating devices, pads, and vias, the union of the board lines of the specified multiple layers can be precisely calculated |
Returns
Promise<IPCB_ComplexPolygon | undefined>
Complex polygon. If the primitive ID does not match or the primitive does not exist on the specified layer, undefined is returned
Example
javascript
// 1. 创建顶层圆形焊盘作为测试图元
const pad = await eda.pcb_PrimitivePad.create(1, '1', 2000, 2000, 0, ['ELLIPSE', 80, 80], '', null, 0, 0, 0, false, 0);
const primitiveId = pad.getState_PrimitiveId();
// 2. 计算边框线:文档签名为同步返回,实测返回 Promise(第二参数可指定参与计算的层)
const pending = eda.pcb_Primitive.getPrimitiveBoardLine(primitiveId, [1]);
// 3. 等待 3 秒观察结果状态(当前版本 Promise 不 settle,用超时保护避免卡住)
const settled = await Promise.race([
Promise.resolve(pending).then(() => 'fulfilled', () => 'rejected'),
new Promise(resolve => setTimeout(() => resolve('pending(3 秒内未返回)'), 3000)),
]);
// 4. 清理测试图元(查询类需要清理)
await eda.pcb_PrimitivePad.delete([primitiveId]);
console.log('primitiveId:', primitiveId);
console.log('returns:', typeof pending.then === 'function' ? 'Promise' : typeof pending);
console.log('settled:', settled);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