Home > PCB_PrimitiveDimension > modify
PCB_PrimitiveDimension.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 dimension
Signature
typescript
function modify(
primitiveId: string | IPCB_PrimitiveDimension,
property: {
dimensionType?:
| undefined
| EPCB_PrimitiveDimensionType.RADIUS
| EPCB_PrimitiveDimensionType.LENGTH
| EPCB_PrimitiveDimensionType.ANGLE;
coordinateSet?: undefined | any | any;
layer?:
| undefined
| EPCB_LayerId.TOP_SILKSCREEN
| EPCB_LayerId.BOTTOM_SILKSCREEN
| EPCB_LayerId.DOCUMENT
| EPCB_LayerId.MECHANICAL
| EPCB_LayerId.CUSTOM_1
| EPCB_LayerId.CUSTOM_2
| EPCB_LayerId.CUSTOM_3
| EPCB_LayerId.CUSTOM_4
| EPCB_LayerId.CUSTOM_5
| EPCB_LayerId.CUSTOM_6
| EPCB_LayerId.CUSTOM_7
| EPCB_LayerId.CUSTOM_8
| EPCB_LayerId.CUSTOM_9
| EPCB_LayerId.CUSTOM_10
| EPCB_LayerId.CUSTOM_11
| EPCB_LayerId.CUSTOM_12
| EPCB_LayerId.CUSTOM_13
| EPCB_LayerId.CUSTOM_14
| EPCB_LayerId.CUSTOM_15
| EPCB_LayerId.CUSTOM_16
| EPCB_LayerId.CUSTOM_17
| EPCB_LayerId.CUSTOM_18
| EPCB_LayerId.CUSTOM_19
| EPCB_LayerId.CUSTOM_20
| EPCB_LayerId.CUSTOM_21
| EPCB_LayerId.CUSTOM_22
| EPCB_LayerId.CUSTOM_23
| EPCB_LayerId.CUSTOM_24
| EPCB_LayerId.CUSTOM_25
| EPCB_LayerId.CUSTOM_26
| EPCB_LayerId.CUSTOM_27
| EPCB_LayerId.CUSTOM_28
| EPCB_LayerId.CUSTOM_29
| EPCB_LayerId.CUSTOM_30;
unit?:
| undefined
| ESYS_Unit.MILLIMETER
| ESYS_Unit.CENTIMETER
| ESYS_Unit.INCH
| ESYS_Unit.MIL;
lineWidth?: undefined | number;
precision?: undefined | number;
primitiveLock?: undefined | false | true;
},
): Promise<IPCB_PrimitiveDimension | undefined>;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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Parameters
Returns
Promise<IPCB_PrimitiveDimension | undefined>
Dimension primitive object
Example
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