Home > SCH_PrimitiveAttribute > getAll
SCH_PrimitiveAttribute.getAll() 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 all Property
Signature
typescript
function getAll(parentPrimitiveId?: string): Promise<Array<ISCH_PrimitiveAttribute>>;1
Parameters
Parameter | Type | Description |
|---|---|---|
parentPrimitiveId | string | (Optional) Parent primitive ID |
Returns
Promise<Array<ISCH_PrimitiveAttribute>>
Array of Property primitive objects
Remarks
If no parent primitive ID is passed, all attribute primitives in the sheet will be obtained
Example
javascript
// 1. 放置一个测试器件(属性图元随器件生成,无法单独创建)
const devices = await eda.lib_Device.search('');
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
const comp = await eda.sch_PrimitiveComponent.create(devices[0], x, y);
const compId = comp.getState_PrimitiveId();
// 2. 传父图元 ID,拿到该器件的全部属性
const compAttrs = await eda.sch_PrimitiveAttribute.getAll(compId);
const keys = compAttrs.map(a => a.getState_Key());
// 3. 不传参数,拿到当前图页上的所有属性图元
const allAttrs = await eda.sch_PrimitiveAttribute.getAll();
// 4. 清理测试器件(属性图元随器件一起删除)
await eda.sch_PrimitiveComponent.delete([compId]);
console.log('component attr count:', compAttrs.length);
console.log('keys:', keys.join(', '));
console.log('page total attrs:', allAttrs.length);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20