Home > PCB_PrimitiveLine > modify
PCB_PrimitiveLine.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 line
Signature
typescript
function modify(
primitiveId: string | IPCB_PrimitiveLine,
property: {
net?: string;
layer?: TPCB_LayersOfLine;
startX?: number;
startY?: number;
endX?: number;
endY?: number;
lineWidth?: number;
primitiveLock?: boolean;
},
): Promise<IPCB_PrimitiveLine | undefined>;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
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveId | string | IPCB_PrimitiveLine | Primitive ID |
property | { net?: string; layer?: TPCB_LayersOfLine; startX?: number; startY?: number; endX?: number; endY?: number; lineWidth?: number; primitiveLock?: boolean } | Modify Parameter |
Returns
Promise<IPCB_PrimitiveLine | undefined>
Line primitive object
Example
javascript
// 1. 创建待修改的测试直线(随机坐标避免与画布已有直线重合)
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
const line = await eda.pcb_PrimitiveLine.create('', 1, x, y, x + 600, y, 10, false);
const lineId = line.getState_PrimitiveId();
// 2. 读取修改前的线宽与终点 X
const beforeWidth = line.getState_LineWidth();
const beforeEndX = line.getState_EndX();
// 3. 批量修改:线宽 10 → 24,终点右移 400mil
await eda.pcb_PrimitiveLine.modify(lineId, { lineWidth: 24, endX: x + 1000 });
// 4. modify 返回后需要重新 get() 才能读到画布上的最新值
const refreshed = await eda.pcb_PrimitiveLine.get(lineId);
// 5. 修改类保留现场,供观察修改结果
console.log('primitiveId:', lineId);
console.log('lineWidth:', beforeWidth, '→', refreshed.getState_LineWidth());
console.log('endX:', beforeEndX, '→', refreshed.getState_EndX());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20