Home > PCB_PrimitivePad > modify
PCB_PrimitivePad.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 Pad
Signature
function modify(
primitiveId: string | IPCB_PrimitivePad,
property: {
layer?: TPCB_LayersOfPad;
padNumber?: string;
x?: number;
y?: number;
rotation?: number;
pad?: TPCB_PrimitivePadShape;
net?: string;
hole?: TPCB_PrimitivePadHole | null;
holeOffsetX?: number;
holeOffsetY?: number;
holeRotation?: number;
metallization?: boolean;
specialPad?: TPCB_PrimitiveSpecialPadShape;
solderMaskAndPasteMaskExpansion?: IPCB_PrimitiveSolderMaskAndPasteMaskExpansion | null;
heatWelding?: IPCB_PrimitivePadHeatWelding | null;
primitiveLock?: boolean;
},
): Promise<IPCB_PrimitivePad | undefined>;2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveId | string | IPCB_PrimitivePad | Primitive ID |
property | { layer?: TPCB_LayersOfPad; padNumber?: string; x?: number; y?: number; rotation?: number; pad?: TPCB_PrimitivePadShape; net?: string; hole?: TPCB_PrimitivePadHole | null; holeOffsetX?: number; holeOffsetY?: number; holeRotation?: number; metallization?: boolean; specialPad?: TPCB_PrimitiveSpecialPadShape; solderMaskAndPasteMaskExpansion?: IPCB_PrimitiveSolderMaskAndPasteMaskExpansion | null; heatWelding?: IPCB_PrimitivePadHeatWelding | null; primitiveLock?: boolean } | Modify Parameter |
Returns
Promise<IPCB_PrimitivePad | undefined>
Pad primitive object
Example
// 1. 创建待修改的测试焊盘(随机坐标避免与画布已有焊盘重合)
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
const pad = await eda.pcb_PrimitivePad.create(1, '1', x, y, 0, ['ELLIPSE', 60, 60], '', null, 0, 0, 0, false, 0);
const padId = pad.getState_PrimitiveId();
// 2. 读取修改前的编号与旋转
const beforeNumber = pad.getState_PadNumber();
const beforeRotation = pad.getState_Rotation();
// 3. 批量修改:编号 '1' → 'A1',旋转 0 → 45 度
await eda.pcb_PrimitivePad.modify(padId, { padNumber: 'A1', rotation: 45 });
// 4. modify 返回后需要重新 get() 才能读到画布上的最新值
const refreshed = await eda.pcb_PrimitivePad.get(padId);
// 5. 修改类保留现场,供观察修改结果
console.log('primitiveId:', padId);
console.log('padNumber:', beforeNumber, '→', refreshed.getState_PadNumber());
console.log('rotation:', beforeRotation, '→', refreshed.getState_Rotation());2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20