Home > LIB_Device > create
LIB_Device.create() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建器件
签名
function create(
libraryUuid: string,
deviceName: string,
classification?: ILIB_ClassificationIndex | Array<string>,
association?: {
symbolType?:
| undefined
| ELIB_SymbolType.COMPONENT
| ELIB_SymbolType.NET_FLAG
| ELIB_SymbolType.NET_PORT
| ELIB_SymbolType.DRAWING
| ELIB_SymbolType.NON_ELECTRICAL
| ELIB_SymbolType.SHORT_CIRCUIT_FLAG
| ELIB_SymbolType.OFF_PAGE_CONNECTOR
| ELIB_SymbolType.DIFFERENTIAL_PAIRS_FLAG
| ELIB_SymbolType.CBB_SYMBOL;
symbolUuid?: undefined | string;
symbol?: undefined | { uuid: string; libraryUuid: string };
footprintUuid?: undefined | string;
footprint?: undefined | { uuid: string; libraryUuid: string };
model3D?: undefined | { uuid: string; libraryUuid: string };
imageData?: undefined | File | Blob;
},
description?: string,
property?: ILIB_DeviceExtendPropertyItem,
): Promise<string | undefined>;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
参数名
参数 | 类型 | 描述 |
|---|---|---|
libraryUuid | string | 库 UUID,可以使用 LIB_LibrariesList 内的接口获取 |
deviceName | string | 器件名称 |
classification | ILIB_ClassificationIndex | Array<string> | (可选) 分类 |
association | { symbolType?: undefined | ELIB_SymbolType.COMPONENT | ELIB_SymbolType.NET_FLAG | ELIB_SymbolType.NET_PORT | ELIB_SymbolType.DRAWING | ELIB_SymbolType.NON_ELECTRICAL | ELIB_SymbolType.SHORT_CIRCUIT_FLAG | ELIB_SymbolType.OFF_PAGE_CONNECTOR | ELIB_SymbolType.DIFFERENTIAL_PAIRS_FLAG | ELIB_SymbolType.CBB_SYMBOL; symbolUuid?: undefined | string; symbol?: undefined | { uuid: string; libraryUuid: string }; footprintUuid?: undefined | string; footprint?: undefined | { uuid: string; libraryUuid: string }; model3D?: undefined | { uuid: string; libraryUuid: string }; imageData?: undefined | File | Blob } | (可选) 关联符号、封装、图像,指定 |
description | string | (可选) 描述 |
property | (可选) 其它属性,仅 |
返回值
Promise<string | undefined>
器件 UUID
示例
// 1. 获取个人库 UUID
const libraryUuid = await eda.lib_LibrariesList.getPersonalLibraryUuid();
// 2. 创建器件:新建元件符号(symbolType: 2)并设置默认属性
const deviceName = `嘉立创示例_新器件_${Date.now()}`;
const deviceUuid = await eda.lib_Device.create(
libraryUuid,
deviceName,
[],
{ symbolType: 2 },
'示例器件描述',
{ designator: 'R', addIntoBom: true, addIntoPcb: true }
);
// 创建类保留现场(新器件留在个人库中供观察)
console.log('deviceUuid:', deviceUuid);
console.log('deviceName:', deviceName);2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18