Home > LIB_Cbb > openSymbolInEditor
LIB_Cbb.openSymbolInEditor() 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 symbol
Signature
typescript
function openSymbolInEditor(
cbbUuid: string,
libraryUuid: string,
splitScreenId?: string,
): Promise<string | undefined>;1
2
3
4
5
2
3
4
5
Parameters
Parameter | Type | Description |
|---|---|---|
cbbUuid | string | Reuse block UUID |
libraryUuid | string | Library UUID, you can use LIB_LibrariesList APIs in |
splitScreenId | string | (Optional) Split screen ID. If not filled in, it opens in the split screen with the last input focus by default. It can be obtained using the APIs in DMT_EditorControl |
Returns
Promise<string | undefined>
Tab ID, corresponding to IDMT_EditorTabItem.tabId. You can use DMT_EditorControl.getSplitScreenIdByTabId() to get the split screen ID
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. 先打开模块工程(openSymbolInEditor 的前置条件)
await eda.lib_Cbb.openProjectInEditor(cbbUuid, personalLib);
await new Promise(r => setTimeout(r, 1000));
// 4. 在编辑器打开模块符号,返回标签页 ID
const tabId = await eda.lib_Cbb.openSymbolInEditor(cbbUuid, personalLib);
// 5. 恢复原来打开的工程
await eda.dmt_Project.openProject(projectInfo.uuid);
console.log('source:', source.name, source.uuid);
console.log('tabId:', tabId);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22