Home > PCB_SelectControl > clearSelected
PCB_SelectControl.clearSelected() 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.
Clear the selection
Signature
typescript
function clearSelected(): Promise<boolean>;1
Returns
Promise<boolean>
Whether the operation is successful
Example
javascript
// 1. 创建测试焊盘并选中它
const pad = await eda.pcb_PrimitivePad.create(1, '1', 2000, 2000, 0, ['ELLIPSE', 60, 60], '', null, 0, 0, 0, false, 0);
const padId = pad.getState_PrimitiveId();
await eda.pcb_SelectControl.doSelectPrimitives([padId]);
// 2. 确认清除前有选中图元
const beforeIds = await eda.pcb_SelectControl.getAllSelectedPrimitives_PrimitiveId();
console.log('清除前选中数量:', beforeIds.length);
// 3. 清除选中
const cleared = await eda.pcb_SelectControl.clearSelected();
console.log('cleared:', cleared);
// 4. 确认选中集已清空
const afterIds = await eda.pcb_SelectControl.getAllSelectedPrimitives_PrimitiveId();
console.log('清除后选中数量:', afterIds.length);
// 5. 清理测试图元
await eda.pcb_PrimitivePad.delete([padId]);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