Home > SCH_PrimitivePin > create
SCH_PrimitivePin.create() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建引脚
签名
typescript
function create(
x: number,
y: number,
pinNumber: string,
pinName?: string,
rotation?: number,
pinLength?: number,
pinColor?: string | null,
pinShape?: ESCH_PrimitivePinShape,
pinType?: ESCH_PrimitivePinType,
): Promise<ISCH_PrimitivePin | undefined>;1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
参数名
参数 | 类型 | 描述 |
|---|---|---|
x | number | 坐标 X |
y | number | 坐标 Y |
pinNumber | string | 引脚编号 |
pinName | string | (可选) 引脚名称 |
rotation | number | (可选) 旋转角度,可选 |
pinLength | number | (可选) 引脚长度 |
pinColor | string | null | (可选) 引脚颜色, |
pinShape | (可选) 引脚形状 | |
pinType | (可选) 引脚类型 |
返回值
Promise<ISCH_PrimitivePin | undefined>
引脚图元对象
示例
javascript
// 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. 随机放置坐标,避免与符号上已有引脚重合(SCH 坐标单位 10mil)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 2. 创建编号 1、名为 CLK 的引脚:朝向 90 度、长 20、红色、时钟形状、输入类型
const pin = await eda.sch_PrimitivePin.create(x, y, '1', 'CLK', 90, 20, '#FF0000', 'Clock', 'IN');
// 3. 创建类保留现场,不删除图元
console.log('primitiveId:', pin.getState_PrimitiveId());
console.log('primitiveType:', pin.getState_PrimitiveType());
console.log('pinNumber:', pin.getState_PinNumber(), 'pinName:', pin.getState_PinName());
console.log('x:', pin.getState_X(), 'y:', pin.getState_Y());
console.log('pinLength:', pin.getState_PinLength());
console.log('pinColor:', pin.getState_PinColor());
console.log('pinShape:', pin.getState_PinShape(), 'pinType:', pin.getState_pinType());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23