PCB_Layer.lockLayer() 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.
Lock the layer
Signature
typescript
function lockLayer(
layer?: TPCB_LayersInTheSelectable | Array<TPCB_LayersInTheSelectable>,
): Promise<boolean>;1
2
3
2
3
Parameters
Parameter | Type | Description |
|---|---|---|
layer | TPCB_LayersInTheSelectable | Array<TPCB_LayersInTheSelectable> | (Optional) Layer. If no layer is specified, all layers are used by default |
Returns
Promise<boolean>
Whether the operation is successful
Example
javascript
// 1. 锁定顶层(TOP=1)与底层(BOTTOM=2),传入层数组
const lockResult = await eda.pcb_Layer.lockLayer([1, 2]);
// 2. 从图层列表确认锁定状态
const layers = await eda.pcb_Layer.getAllLayers();
const top = layers.find(l => l.id === 1);
// 3. 恢复现场:解锁这两层,避免影响后续编辑
const restoreResult = await eda.pcb_Layer.unlockLayer([1, 2]);
console.log('lockResult:', lockResult);
console.log('topLockedNow:', top?.locked);
console.log('restoreResult:', restoreResult);1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13