Home > SCH_Primitive > getPrimitivesBBox
SCH_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 | ISCH_Primitive>,
): Promise<{ minX: number; minY: number; maxX: number; maxY: number } | undefined>;1
2
3
2
3
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveIds | Array<string | ISCH_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. 创建两个测试矩形:左上角(1000,1000)尺寸 200x100,左上角(1600,1400)尺寸 150x80
const rect1 = await eda.sch_PrimitiveRectangle.create(1000, 1000, 200, 100);
const rect2 = await eda.sch_PrimitiveRectangle.create(1600, 1400, 150, 80);
// 2. 计算两个矩形整体的 BBox(传图元 ID 数组,也支持直接传图元对象数组)
const bbox = await eda.sch_Primitive.getPrimitivesBBox([
rect1.getState_PrimitiveId(),
rect2.getState_PrimitiveId(),
]);
// 3. 清理测试图元(查询类需要清理)
await eda.sch_PrimitiveRectangle.delete([
rect1.getState_PrimitiveId(),
rect2.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
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20