Home > SCH_PrimitivePin > get
SCH_PrimitivePin.get() 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.
Get Pin
Signature
typescript
function get(
primitiveIds: string,
): Promise<ISCH_PrimitivePin | ISCH_PrimitiveComponentPin | undefined>;1
2
3
2
3
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveIds | string | Pin primitive ID, which can be a string or an array of strings. If it is an array, an array is also returned |
Returns
Promise<ISCH_PrimitivePin | ISCH_PrimitiveComponentPin | undefined>
Pin primitive object, undefined indicates that the retrieval failed
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. 在符号画布上创建两个测试引脚(随机坐标避免重合)
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