Home > SCH_SelectControl > clearSelected
SCH_SelectControl.clearSelected() method
Clear the selection
Signature
typescript
function clearSelected(): boolean;1
Returns
boolean
Whether the operation is successful
Example
javascript
// 1. 创建测试矩形并选中它
const rect = await eda.sch_PrimitiveRectangle.create(400, 300, 200, 100);
const rectId = rect.getState_PrimitiveId();
await eda.sch_SelectControl.doSelectPrimitives([rectId]);
// 2. 确认清除前有选中图元
const beforeIds = await eda.sch_SelectControl.getAllSelectedPrimitives_PrimitiveId();
console.log('清除前选中数量:', beforeIds.length);
// 3. 清除选中(同步方法,直接返回结果)
const cleared = eda.sch_SelectControl.clearSelected();
console.log('cleared:', cleared);
// 4. 确认选中集已清空
const afterIds = await eda.sch_SelectControl.getAllSelectedPrimitives_PrimitiveId();
console.log('清除后选中数量:', afterIds.length);
// 5. 清理测试图元
await eda.sch_PrimitiveRectangle.delete([rectId]);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