Home > PCB_Primitive > getPrimitivesBBox
PCB_Primitive.getPrimitivesBBox() 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 BBox of the primitive
Signature
typescript
function getPrimitivesBBox(
primitiveIds: Array<string | IPCB_Primitive>,
): Promise<{ minX: number; minY: number; maxX: number; maxY: number } | undefined>;1
2
3
2
3
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveIds | Array<string | IPCB_Primitive> | Array of Primitive ID array or primitive objects |
Returns
Promise<{ minX: number; minY: number; maxX: number; maxY: number } | undefined>
The BBox of the primitive. If the primitive does not exist or has no BBox, undefined will be returned
Example
javascript
// 1. 创建两个顶层测试焊盘:一个 80x80 放在(2000,2000),一个 60x60 放在(3000,3000)
const pad1 = await eda.pcb_PrimitivePad.create(1, '1', 2000, 2000, 0, ['ELLIPSE', 80, 80], '', null, 0, 0, 0, false, 0);
const pad2 = await eda.pcb_PrimitivePad.create(1, '2', 3000, 3000, 0, ['ELLIPSE', 60, 60], '', null, 0, 0, 0, false, 0);
// 2. 计算两个焊盘整体的 BBox(传图元 ID 数组,也支持直接传图元对象数组)
const bbox = await eda.pcb_Primitive.getPrimitivesBBox([pad1.getState_PrimitiveId(), pad2.getState_PrimitiveId()]);
// 3. 清理测试图元(查询类需要清理)
await eda.pcb_PrimitivePad.delete([pad1.getState_PrimitiveId(), pad2.getState_PrimitiveId()]);
console.log('minX:', bbox.minX);
console.log('minY:', bbox.minY);
console.log('maxX:', bbox.maxX);
console.log('maxY:', bbox.maxY);1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14