Home > SCH_PrimitiveBus > modify
SCH_PrimitiveBus.modify() 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 the bus
Signature
typescript
function modify(
primitiveId: string | ISCH_PrimitiveBus,
property: {
busName?: undefined | string;
line?: undefined | number[] | number[][];
color?: undefined | null | string;
lineWidth?: undefined | null | number;
lineType?:
| undefined
| null
| ESCH_PrimitiveLineType.SOLID
| ESCH_PrimitiveLineType.DASHED
| ESCH_PrimitiveLineType.DOTTED
| ESCH_PrimitiveLineType.DOT_DASHED;
},
): Promise<ISCH_PrimitiveBus | undefined>;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
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveId | string | ISCH_PrimitiveBus | Primitive ID of the bus or the bus primitive object |
property | { busName?: undefined | string; line?: undefined | number[] | number[][]; color?: undefined | null | string; lineWidth?: undefined | null | number; lineType?: undefined | null | ESCH_PrimitiveLineType.SOLID | ESCH_PrimitiveLineType.DASHED | ESCH_PrimitiveLineType.DOTTED | ESCH_PrimitiveLineType.DOT_DASHED } | Modify Parameter |
Returns
Promise<ISCH_PrimitiveBus | undefined>
Bus primitive object
Example
javascript
// 1. 创建待修改的测试总线(随机坐标避免与画布已有总线重合)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
const bus = await eda.sch_PrimitiveBus.create('DATA[0..7]', [x, y, x + 400, y], '#FF0000', 6, 1);
const busId = bus.getState_PrimitiveId();
// 2. 读取修改前的名称、线宽与颜色
const beforeName = bus.getState_BusName();
const beforeWidth = bus.getState_LineWidth();
const beforeColor = bus.getState_Color();
// 3. 批量修改:名称 DATA[0..7] → ADDR[0..15]、线宽 6 → 10、颜色改为绿色
await eda.sch_PrimitiveBus.modify(busId, { busName: 'ADDR[0..15]', lineWidth: 10, color: '#00AA00' });
// 4. modify 返回后需要重新 get() 才能读到画布上的最新值
const refreshed = await eda.sch_PrimitiveBus.get(busId);
// 5. 修改类保留现场,供观察修改结果
console.log('primitiveId:', busId);
console.log('busName:', beforeName, '→', refreshed.getState_BusName());
console.log('lineWidth:', beforeWidth, '→', refreshed.getState_LineWidth());
console.log('color:', beforeColor, '→', refreshed.getState_Color());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22