Home > LIB_LibrariesList > registerExtendLibrary
LIB_LibrariesList.registerExtendLibrary() 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.
Register an external library
Signature
typescript
function registerExtendLibrary(
title: string,
libraryFunctions: {
device?: undefined | ILIB_ExtendLibraryDeviceFunctions;
symbol?: undefined | ILIB_ExtendLibrarySymbolFunctions;
footprint?: undefined | ILIB_ExtendLibraryFootprintFunctions;
cbb?: undefined | ILIB_ExtendLibraryCbbFunctions;
model3d?: undefined | ILIB_ExtendLibrary3DModelFunctions;
},
): Promise<string | undefined>;1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
Parameters
Parameter | Type | Description |
|---|---|---|
title | string | Title |
libraryFunctions | { device?: undefined | ILIB_ExtendLibraryDeviceFunctions; symbol?: undefined | ILIB_ExtendLibrarySymbolFunctions; footprint?: undefined | ILIB_ExtendLibraryFootprintFunctions; cbb?: undefined | ILIB_ExtendLibraryCbbFunctions; model3d?: undefined | ILIB_ExtendLibrary3DModelFunctions } |
Returns
Promise<string | undefined>
Library UUID
Remarks
Note: This API is only valid for extensions. Calling it in a standalone script environment will always throw Error
Example
javascript
// 1. 实现外部库的符号数据回调(真实场景中在此对接自己的数据源)
const symbolFunctions = {
// 分类树:库面板左侧的分类目录
getClassificationTree: async () => [
{ name: '电阻', uuid: 'resistor' },
{ name: '电容', uuid: 'capacitor' }
],
// 列表搜索:响应用户的关键字搜索与分页,返回分页结构
getList: async (props) => {
const all = [{ uuid: 'demo_0402', title: '示例符号 0402' }];
return {
count: all.length,
lists: all,
page: props.page || 1,
pageSize: props.pageSize || 10,
totalPage: 1
};
},
// 详情:用户选中条目后获取完整信息
getDetail: async (uuid) => {
return { uuid, title: '示例符号 0402' };
}
};
// 2. 以指定标题注册外部库,挂载符号类型资源
const libUuid = await eda.lib_LibrariesList.registerExtendLibrary('嘉立创示例_外部库', {
symbol: symbolFunctions
});
// 3. 输出注册结果,库面板中即可看到「嘉立创示例_外部库」
console.log('libUuid:', libUuid);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
30
31
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
30
31