Home > PCB_Net > setNetColor
PCB_Net.setNetColor() 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.
Set the color of the specified net
Signature
typescript
function setNetColor(net: string, color: IPCB_NetInfo['color']): Promise<boolean>;1
Parameters
Parameter | Type | Description |
|---|---|---|
net | string | Net name |
color | IPCB_NetInfo['color'] | Net color |
Returns
Promise<boolean>
Whether Set Successful, false is does not exist this net
Example
javascript
// 1. 创建带网络名的过孔,让 PCB 中出现可操作的网络
const via = await eda.pcb_PrimitiveVia.create('嘉立创示例_NET1', 2000, 2000, 20, 40);
// 2. 记录修改前的颜色
const before = await eda.pcb_Net.getNetColor('嘉立创示例_NET1');
// 3. 将网络设置为红色(修改类保留现场,便于在画布上观察效果)
const colorSet = await eda.pcb_Net.setNetColor('嘉立创示例_NET1', { r: 255, g: 0, b: 0, alpha: 1 });
// 4. 重新读取颜色,验证修改已生效
const after = await eda.pcb_Net.getNetColor('嘉立创示例_NET1');
console.log('colorSet:', colorSet);
console.log('before:', before);
console.log('after:', after);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15