Home > PCB_SelectControl > doSelectPrimitives
PCB_SelectControl.doSelectPrimitives() 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.
Select primitives using primitive IDs
Signature
typescript
function doSelectPrimitives(primitiveIds: string | Array<string>): Promise<boolean>;1
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveIds | string | Array<string> | Primitive ID |
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();
// 2. 用图元 ID 选中焊盘
const selected = await eda.pcb_SelectControl.doSelectPrimitives([padId]);
console.log('selected:', selected);
// 3. 确认焊盘已在选中集里
const selectedIds = await eda.pcb_SelectControl.getAllSelectedPrimitives_PrimitiveId();
console.log('选中数量:', selectedIds.length);
console.log('包含测试焊盘:', selectedIds.includes(padId));
// 4. 清理:清除选中并删除测试图元
await eda.pcb_SelectControl.clearSelected();
await eda.pcb_PrimitivePad.delete([padId]);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16