Home > SCH_PrimitivePin > modify
SCH_PrimitivePin.modify() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
修改引脚
签名
function modify(
primitiveId: string | ISCH_PrimitivePin | ISCH_PrimitiveComponentPin,
property: {
x?: undefined | number;
y?: undefined | number;
pinNumber?: undefined | string;
pinName?: undefined | string;
rotation?: undefined | number;
pinLength?: undefined | number;
pinColor?: undefined | null | string;
pinShape?:
| undefined
| ESCH_PrimitivePinShape.NONE
| ESCH_PrimitivePinShape.INVERTED
| ESCH_PrimitivePinShape.CLOCK
| ESCH_PrimitivePinShape.INVERTED_CLOCK;
pinType?:
| undefined
| ESCH_PrimitivePinType.IN
| ESCH_PrimitivePinType.OUT
| ESCH_PrimitivePinType.BI
| ESCH_PrimitivePinType.PASSIVE
| ESCH_PrimitivePinType.OPEN_COLLECTOR
| ESCH_PrimitivePinType.OPEN_EMITTER
| ESCH_PrimitivePinType.POWER
| ESCH_PrimitivePinType.GROUND
| ESCH_PrimitivePinType.HIZ
| ESCH_PrimitivePinType.TERMINATOR
| ESCH_PrimitivePinType.UNDEFINED;
noConnected?: undefined | false | true;
otherProperty?: undefined | Record<string, string | number | false | true>;
},
): Promise<ISCH_PrimitivePin | ISCH_PrimitiveComponentPin | undefined>;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
参数名
参数 | 类型 | 描述 |
|---|---|---|
primitiveId | string | ISCH_PrimitivePin | ISCH_PrimitiveComponentPin | 图元 ID |
property | { x?: undefined | number; y?: undefined | number; pinNumber?: undefined | string; pinName?: undefined | string; rotation?: undefined | number; pinLength?: undefined | number; pinColor?: undefined | null | string; pinShape?: undefined | ESCH_PrimitivePinShape.NONE | ESCH_PrimitivePinShape.INVERTED | ESCH_PrimitivePinShape.CLOCK | ESCH_PrimitivePinShape.INVERTED_CLOCK; pinType?: undefined | ESCH_PrimitivePinType.IN | ESCH_PrimitivePinType.OUT | ESCH_PrimitivePinType.BI | ESCH_PrimitivePinType.PASSIVE | ESCH_PrimitivePinType.OPEN_COLLECTOR | ESCH_PrimitivePinType.OPEN_EMITTER | ESCH_PrimitivePinType.POWER | ESCH_PrimitivePinType.GROUND | ESCH_PrimitivePinType.HIZ | ESCH_PrimitivePinType.TERMINATOR | ESCH_PrimitivePinType.UNDEFINED; noConnected?: undefined | false | true; otherProperty?: undefined | Record<string, string | number | false | true> } | 修改参数 |
返回值
Promise<ISCH_PrimitivePin | ISCH_PrimitiveComponentPin | undefined>
引脚图元对象
示例
// 0. 引脚图元仅符号编辑器可用:优先复用测试符号,没有则新建后打开
// (当前版本非空关键字 search 会抛错,用空关键字列出后按名称过滤)
const libUuid = await eda.lib_LibrariesList.getPersonalLibraryUuid();
const found = await eda.lib_Symbol.search('', libUuid, [], undefined, 100, 1);
const hit = found.find(s => s.name === '嘉立创示例_Pin测试符号');
const symUuid = hit ? hit.uuid : await eda.lib_Symbol.create(libUuid, '嘉立创示例_Pin测试符号');
await eda.lib_Symbol.openInEditor(symUuid, libUuid);
// 1. 创建待修改的测试引脚(随机坐标避免重合)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
const pin = await eda.sch_PrimitivePin.create(x, y, '1', 'CLK', 0, 10, null, 'None', 'IN');
const pinId = pin.getState_PrimitiveId();
// 2. 记录修改前的编号、名称与长度
const beforeNumber = pin.getState_PinNumber();
const beforeName = pin.getState_PinName();
const beforeLength = pin.getState_PinLength();
// 3. 批量修改:编号 1 → 7、名称 CLK → XTAL、长度 10 → 20、朝向 0 → 90 度
await eda.sch_PrimitivePin.modify(pinId, { pinNumber: '7', pinName: 'XTAL', pinLength: 20, rotation: 90 });
// 4. modify 返回后需要重新 get() 才能读到画布上的最新值
const refreshed = await eda.sch_PrimitivePin.get(pinId);
// 5. 修改类保留现场,供观察修改结果
console.log('primitiveId:', pinId);
console.log('pinNumber:', beforeNumber, '→', refreshed.getState_PinNumber());
console.log('pinName:', beforeName, '→', refreshed.getState_PinName());
console.log('pinLength:', beforeLength, '→', refreshed.getState_PinLength());
console.log('rotation:', pin.getState_Rotation(), '→', refreshed.getState_Rotation());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