Scripting Document Operations¶
Prerequisites¶
The following methods are exposed by the DocumentControl object implemented by the module Thinkbox.Sequoia.Documents
Before calling these methods, you must ensure the module is imported.
import Thinkbox.Sequoia.Documents 1.0
DocumentControl Methods¶
Get/Set Current Document¶
<String> DocumentControl.getCurrentDocument ()
Returns the ID of the current (Active) Document.
<void> DocumentControl.setCurrentDocument ( <String>documentId )
Sets the current (Active) Document to the specified Document ID.
Set Default Directory¶
<void> DocumentControl.setDefaultDirectory ( <String>directory )
Sets the default directory where the File > Open dialog will look for files.
Example:
DocumentControl.setDefaultDirectory ("c:/temp"); //set the default directory
DocumentControl.open(); //open the file dialog at the default directory
Get Documents List¶
<sringList> DocumentControl.getRecentFileList ()
Returns the list of recently edited Documents.
Equivalent to the File > Open RECENT Document… > list in the UI.
<stringList> DocumentControl.getAllDocuments ()
Returns a list of the IDs of all currently opened Documents.
<stringList> DocumentControl.getAllDocumentNames ()
Returns a list of the names of all currently opened Documents.
Save Viewport To Document¶
<void> DocumentControl.saveViewportsToDocument ( <String>documentId )
Document Creation¶
<String> DocumentControl.createDocument ()
Creates a new Document.
Does NOT switch to the new Document.
Example:
var newdoc = DocumentControl.createDocument(DocumentControl.getCurrentDocument());
DocumentControl.setCurrentDocument(newdoc);
<String> DocumentControl.cloneDocument ( <String>documentId )
Creates a clone of the Document with the given Document ID, and returns the new Document’s ID.
Open Document¶
<String> DocumentControl.open ()
Opens the Open File dialog and lets the user select an existing .SQ file to load.
If a valid file is selected, it will be loaded as a new Document.
Returns the Document ID of the new Document.
<String> DocumentControl.open ( <String>filename )
Opens the specified .SQ file without prompting with an Open File dialog.
Returns the Document ID of the new Document.
Example:
DocumentControl.open("c:/temp/test.sq");
Save Document¶
<Bool> DocumentControl.save ( <String>documentId )
Saves the Document specified as argument to its current file name, overwriting the previous file.
If the Document is Untitled, opens the Save File dialog.
Returns true if the file was saved, false if not saved.
Example:
DocumentControl.save(DocumentControl.getCurrentDocument());
<Bool> DocumentControl.saveAs ( <String>documentId, [<String>filename=””] )
Saves the Document to the specified file name if a valid name is specified.
Does not save if the Cancel button is pressed in the Save File Dialog.
If the second optional filename argument is not specified, or if it is specified as an empty string, the Save File dialog will be opened.
Returns true if the Document was saved, false if it was not saved.
Close Document¶
<void> DocumentControl.close ( <String>documentId )
<void> DocumentControl.closeDocument ( <String>documentId )
Both methods close the document with the ID specified by the argument.
Example:
DocumentControl.close(DocumentControl.getCurrentDocument()); //closes the current document
Auto-Update and Auto-Zoom¶
<Bool> DocumentControl.isAutoUpdate ( <String>documentId )
Returns true if the Document’s Auto Update option is checked, false if it is unchecked (default).
<void> DocumentControl.setAutoUpdate ( <Bool>enabled, [ <String>documentId ] )
Sets the Document’s Auto Update option to the specified boolean state.
<Bool> DocumentControl.isAutoZoomExtents ( <String>documentId )
Returns true if the Document’s Auto Zoom option is checked (default), false if it is unchecked.
<void> DocumentControl.setAutoZoomExtents ( <Bool>enabled, [ <String> documentId ] )
Sets the Document’s Auto Zoom option to the specified boolean state.