Home > PCB_Layer > modifyLayer
PCB_Layer.modifyLayer() 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.
Modify Layer properties
Signature
typescript
function modifyLayer(
layer: TPCB_LayersInTheSelectable,
property: {
name?: undefined | string;
type?: undefined | EPCB_LayerType.SIGNAL | EPCB_LayerType.INTERNAL_ELECTRICAL;
color?: undefined | string;
transparency?: undefined | number;
},
): Promise<boolean>;1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Parameters
Parameter | Type | Description |
|---|---|---|
layer | Layer | |
property | { name?: undefined | string; type?: undefined | EPCB_LayerType.SIGNAL | EPCB_LayerType.INTERNAL_ELECTRICAL; color?: undefined | string; transparency?: undefined | number } | Property |
Returns
Promise<boolean>
The modified layer properties. If it is undefined, the modification failed or the layer does not exist
Remarks
Only inner layers and custom layers can have their names modified; only inner layers can have their types modified. Transparency only supports values between 0-100
Example
javascript
// 1. 新增一个自定义层作为修改对象
const customLayerId = await eda.pcb_Layer.addCustomLayer();
// 2. 读取修改前的名称与颜色
const before = (await eda.pcb_Layer.getAllLayers()).find(l => l.id === customLayerId);
// 3. 修改名称、颜色与透明度(保留现场供观察)
const modifyResult = await eda.pcb_Layer.modifyLayer(customLayerId, {
name: '嘉立创示例_工艺说明',
color: '#FF6600',
transparency: 30,
});
// 4. 重新读取图层列表确认修改生效
const after = (await eda.pcb_Layer.getAllLayers()).find(l => l.id === customLayerId);
console.log('modifyResult:', modifyResult);
console.log('nameBefore:', before?.name, '→ nameAfter:', after?.name);
console.log('colorBefore:', before?.color, '→ colorAfter:', after?.color);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