Home > DMT_SelectControl > getCurrentDocumentInfo
DMT_SelectControl.getCurrentDocumentInfo() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
获取当前文档的属性
签名
typescript
function getCurrentDocumentInfo(): Promise<IDMT_EditorDocumentItem | undefined>;1
返回值
Promise<IDMT_EditorDocumentItem | undefined>
文档类型、UUID、所属工程的 UUID、所属库的 UUID 组成的对象,如若为 undefined 则获取失败
备注
将会获取当前打开且拥有最后输入焦点的文档的文档类型、UUID、所属工程的 UUID 或所属库的 UUID
示例
javascript
// 1. 创建专用测试原理图(自带图页 p1),打开该页让焦点落到测试文档上
const schematicUuid = await eda.dmt_Schematic.createSchematic();
await new Promise(r => setTimeout(r, 1500));
const info = await eda.dmt_Schematic.getSchematicInfo(schematicUuid);
const pageUuid = info.page[0].uuid;
await eda.dmt_EditorControl.openDocument(pageUuid);
await new Promise(r => setTimeout(r, 1000));
// 2. 获取当前焦点文档的属性(documentType: 1=原理图, 3=PCB)
const doc = await eda.dmt_SelectControl.getCurrentDocumentInfo();
// 3. 输出文档类型、UUID、标签页与所属工程,确认正是刚打开的测试图页
console.log('documentType:', doc?.documentType);
console.log('documentUuid:', doc?.uuid);
console.log('tabId:', doc?.tabId);
console.log('parentProjectUuid:', doc?.parentProjectUuid);
console.log('isFocusedPage:', doc?.uuid === pageUuid);
// 4. 清理测试原理图(处于打开状态也可以直接删除)
await new Promise(r => setTimeout(r, 1000));
const deleted = await eda.dmt_Schematic.deleteSchematic(schematicUuid);
console.log('deleted:', deleted);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