Home > LIB_Cbb > openProjectInEditor
LIB_Cbb.openProjectInEditor() 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.
Open in the editor reuse block project
Signature
typescript
function openProjectInEditor(cbbUuid: string, libraryUuid: string): Promise<boolean>;1
Parameters
Parameter | Type | Description |
|---|---|---|
cbbUuid | string | Reuse block UUID |
libraryUuid | string | Library UUID, you can use LIB_LibrariesList APIs in |
Returns
Promise<boolean>
Remarks
This operation will open the module project in the EDA front end. If another project was previously opened with unsaved changes, executing this operation will directly lose all unsaved data
Example
javascript
// 1. 记录当前工程,便于演示结束后恢复
const projectInfo = await eda.dmt_Project.getCurrentProjectInfo();
// 2. 复制一个系统库模块到个人库作为打开对象
const systemLib = await eda.lib_LibrariesList.getSystemLibraryUuid();
const personalLib = await eda.lib_LibrariesList.getPersonalLibraryUuid();
const results = await eda.lib_Cbb.search('', systemLib, undefined, 1);
const source = results[0];
const cbbUuid = await eda.lib_Cbb.copy(source.uuid, systemLib, personalLib, [], `嘉立创示例_打开工程_${Date.now()}`);
// 3. 在编辑器打开模块工程
const opened = await eda.lib_Cbb.openProjectInEditor(cbbUuid, personalLib);
// 4. 恢复原来打开的工程
await new Promise(r => setTimeout(r, 1000));
await eda.dmt_Project.openProject(projectInfo.uuid);
console.log('source:', source.name, source.uuid);
console.log('opened:', opened);
console.log('restored:', projectInfo.uuid);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