Home > PCB_PrimitiveString > modify
PCB_PrimitiveString.modify() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
修改文本
签名
typescript
function modify(
primitiveId: string | IPCB_PrimitiveString,
property: {
layer?:
| undefined
| EPCB_LayerId.TOP
| EPCB_LayerId.TOP_SILKSCREEN
| EPCB_LayerId.TOP_SOLDER_MASK
| EPCB_LayerId.TOP_ASSEMBLY
| EPCB_LayerId.BOTTOM
| EPCB_LayerId.BOTTOM_SILKSCREEN
| EPCB_LayerId.BOTTOM_SOLDER_MASK
| EPCB_LayerId.BOTTOM_ASSEMBLY
| EPCB_LayerId.DOCUMENT
| EPCB_LayerId.MECHANICAL
| EPCB_LayerId.INNER_1
| EPCB_LayerId.INNER_2
| EPCB_LayerId.INNER_3
| EPCB_LayerId.INNER_4
| EPCB_LayerId.INNER_5
| EPCB_LayerId.INNER_6
| EPCB_LayerId.INNER_7
| EPCB_LayerId.INNER_8
| EPCB_LayerId.INNER_9
| EPCB_LayerId.INNER_10
| EPCB_LayerId.INNER_11
| EPCB_LayerId.INNER_12
| EPCB_LayerId.INNER_13
| EPCB_LayerId.INNER_14
| EPCB_LayerId.INNER_15
| EPCB_LayerId.INNER_16
| EPCB_LayerId.INNER_17
| EPCB_LayerId.INNER_18
| EPCB_LayerId.INNER_19
| EPCB_LayerId.INNER_20
| EPCB_LayerId.INNER_21
| EPCB_LayerId.INNER_22
| EPCB_LayerId.INNER_23
| EPCB_LayerId.INNER_24
| EPCB_LayerId.INNER_25
| EPCB_LayerId.INNER_26
| EPCB_LayerId.INNER_27
| EPCB_LayerId.INNER_28
| EPCB_LayerId.INNER_29
| EPCB_LayerId.INNER_30
| 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
| EPCB_LayerId.DRILL_DRAWING;
x?: undefined | number;
y?: undefined | number;
text?: undefined | string;
fontFamily?: undefined | string;
fontSize?: undefined | number;
lineWidth?: undefined | number;
alignMode?:
| undefined
| EPCB_PrimitiveStringAlignMode.LEFT_TOP
| EPCB_PrimitiveStringAlignMode.LEFT_MIDDLE
| EPCB_PrimitiveStringAlignMode.LEFT_BOTTOM
| EPCB_PrimitiveStringAlignMode.CENTER_TOP
| EPCB_PrimitiveStringAlignMode.CENTER
| EPCB_PrimitiveStringAlignMode.CENTER_BOTTOM
| EPCB_PrimitiveStringAlignMode.RIGHT_TOP
| EPCB_PrimitiveStringAlignMode.RIGHT_MIDDLE
| EPCB_PrimitiveStringAlignMode.RIGHT_BOTTOM;
rotation?: undefined | number;
reverse?: undefined | false | true;
expansion?: undefined | number;
mirror?: undefined | false | true;
primitiveLock?: undefined | false | true;
},
): Promise<IPCB_PrimitiveString | 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
参数名
返回值
Promise<IPCB_PrimitiveString | undefined>
文本图元对象
示例
javascript
// 1. 创建待修改的测试文本:顶层丝印(3),字号 45(随机坐标避免重合)
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
const text = await eda.pcb_PrimitiveString.create(3, x, y, '嘉立创示例_待修改', 'default', 45, 6, 3, 0, false, 0, false, false);
const textId = text.getState_PrimitiveId();
// 2. 读取修改前的内容与字号
const beforeText = text.getState_Text();
const beforeSize = text.getState_FontSize();
// 3. 批量修改:更换文字内容并把字号从 45 调大到 60
await eda.pcb_PrimitiveString.modify(textId, { text: '嘉立创示例_已更新', fontSize: 60 });
// 4. modify 返回后需要重新 get() 才能读到画布上的最新值
const refreshed = await eda.pcb_PrimitiveString.get(textId);
// 5. 修改类保留现场,供观察修改结果
console.log('primitiveId:', textId);
console.log('text:', beforeText, '→', refreshed.getState_Text());
console.log('fontSize:', beforeSize, '→', refreshed.getState_FontSize());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