Home > DMT_EditorControl > closeDocument
DMT_EditorControl.closeDocument() method
Close document
Signature
typescript
function closeDocument(tabId: string): Promise<boolean>;1
Parameters
Parameter | Type | Description |
|---|---|---|
tabId | string | Tab ID. Here IDMT_SchematicPageItem.uuid, IDMT_PcbItem.uuid, and IDMT_PanelItem.uuid are supported as input |
Returns
Promise<boolean>
Whether the operation is successful
Remarks
If the document has not been saved, executing this operation will directly lose all unsaved data. After completing modification operations, first execute SCH_Document.save(), PCB_Document.save(), and PNL_Document.save() to save the data
Example
javascript
// 1. 创建临时原理图并给它加一页(新建的原理图没有页面,需显式创建)
const schematicUuid = await eda.dmt_Schematic.createSchematic('嘉立创示例_关闭文档');
const pageUuid = await eda.dmt_Schematic.createSchematicPage(schematicUuid);
// 2. 打开该页面作为关闭目标
const tabId = await eda.dmt_EditorControl.openDocument(pageUuid);
console.log('opened tab:', tabId);
// 3. 关闭该标签页(空白文档,无未保存内容)
const closed = await eda.dmt_EditorControl.closeDocument(tabId);
console.log('closed:', closed);
// 4. 删除临时原理图,保持工程整洁
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15