Home > SCH_PrimitivePin > get
SCH_PrimitivePin.get() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
获取引脚
签名
typescript
function get(
primitiveIds: string,
): Promise<ISCH_PrimitivePin | ISCH_PrimitiveComponentPin | undefined>;1
2
3
2
3
参数名
参数 | 类型 | 描述 |
|---|---|---|
primitiveIds | string | 引脚的图元 ID,可以为字符串或字符串数组,如若为数组,则返回的也是数组 |
返回值
Promise<ISCH_PrimitivePin | ISCH_PrimitiveComponentPin | undefined>
引脚图元对象,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. 在符号画布上创建两个测试引脚(随机坐标避免重合)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
const pin1 = await eda.sch_PrimitivePin.create(x, y, '1', 'INA', 0, 10, null, 'None', 'IN');
const pin2 = await eda.sch_PrimitivePin.create(x, y + 200, '2', 'INB', 0, 10, null, 'None', 'OUT');
const id1 = pin1.getState_PrimitiveId();
const id2 = pin2.getState_PrimitiveId();
// 2. 传单个 ID 字符串,返回单个引脚对象
const single = await eda.sch_PrimitivePin.get(id1);
// 3. 传 ID 数组,返回引脚对象数组(任一 ID 未匹配不影响其它图元的返回)
const arr = await eda.sch_PrimitivePin.get([id1, id2]);
// 4. 清理测试引脚(查询类需要清理)
await eda.sch_PrimitivePin.delete([id1, id2]);
console.log('single pinNumber:', single.getState_PinNumber());
console.log('array length:', arr.length);
console.log('pin2 name:', arr[1].getState_PinName());
console.log('pin2 type:', arr[1].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
24
25
26
27
28
29
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