Home > SCH_PrimitivePin > create
SCH_PrimitivePin.create() 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.
Create Pin
Signature
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
Parameters
Parameter | Type | Description |
|---|---|---|
x | number | X coordinate |
y | number | Y coordinate |
pinNumber | string | Pin number |
pinName | string | (Optional) Pin name |
rotation | number | (Optional) Rotation angle. Options: |
pinLength | number | (Optional) Pin length |
pinColor | string | null | (Optional) Pin color, |
pinShape | (Optional) Pin shape | |
pinType | (Optional) Pin type |
Returns
Promise<ISCH_PrimitivePin | undefined>
Pin primitive object
Example
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