Home > PCB_PrimitiveDimension > modify
PCB_PrimitiveDimension.modify() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
修改尺寸标注
签名
typescript
function modify(
primitiveId: string | IPCB_PrimitiveDimension,
property: {
dimensionType?: EPCB_PrimitiveDimensionType;
coordinateSet?: TPCB_PrimitiveDimensionCoordinateSet;
layer?: TPCB_LayersOfDimension;
unit?: ESYS_Unit.MILLIMETER | ESYS_Unit.CENTIMETER | ESYS_Unit.INCH | ESYS_Unit.MIL;
lineWidth?: number;
precision?: number;
primitiveLock?: boolean;
},
): Promise<IPCB_PrimitiveDimension | undefined>;1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
参数名
参数 | 类型 | 描述 |
|---|---|---|
primitiveId | string | IPCB_PrimitiveDimension | 图元 ID |
property | { dimensionType?: EPCB_PrimitiveDimensionType; coordinateSet?: TPCB_PrimitiveDimensionCoordinateSet; layer?: TPCB_LayersOfDimension; unit?: ESYS_Unit.MILLIMETER | ESYS_Unit.CENTIMETER | ESYS_Unit.INCH | ESYS_Unit.MIL; lineWidth?: number; precision?: number; primitiveLock?: boolean } | 修改参数 |
返回值
Promise<IPCB_PrimitiveDimension | undefined>
尺寸标注图元对象
示例
javascript
// 1. 创建待修改的测试标注(随机坐标避免与画布已有标注重合)
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
const dim = await eda.pcb_PrimitiveDimension.create(
'Length Dimension',
[x, y, x, y - 200, x + 2000, y - 200, x + 2000, y],
3,
'mm',
10,
2
);
const dimId = dim.getState_PrimitiveId();
// 2. 读取修改前的线宽与精度
const beforeWidth = dim.getState_LineWidth();
const beforePrecision = dim.getState_Precision();
// 3. 批量修改:线宽 10 → 20,精度 2 → 3
await eda.pcb_PrimitiveDimension.modify(dimId, { lineWidth: 20, precision: 3 });
// 4. modify 返回后需要重新 get() 才能读到画布上的最新值
const refreshed = await eda.pcb_PrimitiveDimension.get(dimId);
// 5. 修改类保留现场,供观察修改结果
console.log('primitiveId:', dimId);
console.log('lineWidth:', beforeWidth, '→', refreshed.getState_LineWidth());
console.log('precision:', beforePrecision, '→', refreshed.getState_Precision());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27