Home > SCH_PrimitiveRectangle > getAllPrimitiveId
SCH_PrimitiveRectangle.getAllPrimitiveId() method
获取所有矩形的图元 ID
签名
typescript
function getAllPrimitiveId(): Promise<Array<string>>;1
返回值
Promise<Array<string>>
矩形的图元 ID 数组
示例
javascript
// 1. 创建一个测试矩形作为查找目标(随机坐标避免重合)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
const rect = await eda.sch_PrimitiveRectangle.create(x, y, 400, 300, 0, 0, '#FF0000');
const rectId = rect.getState_PrimitiveId();
// 2. 获取全部矩形的图元 ID
const allIds = await eda.sch_PrimitiveRectangle.getAllPrimitiveId();
// 3. 清理测试矩形(查询类需要清理)
await eda.sch_PrimitiveRectangle.delete([rectId]);
console.log('total rectangle ids:', allIds.length);
console.log('marker id in list:', allIds.includes(rectId));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