Home > PCB_SelectControl > clearSelected
PCB_SelectControl.clearSelected() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
清除选中
签名
typescript
function clearSelected(): Promise<boolean>;1
返回值
Promise<boolean>
操作是否成功
示例
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