Constructors
DocumentIO
#Create a new empty IO class. Use this constructor if you wish to Open/Load a file.
public DocumentIO()
document = null,
Document to operate on.
trackFiles = true,
True to add recent-file records.
reportErrors = true,
True to show exceptions in an error window.
retainRoot = false,
True to keep the archive root after opening.
resolvePlugins = true
True to offer the user a way to fetch plugins the file needs but does not have. Turn this off for loads which happen behind the user's back — snippet previews, dependency reads — where a modal window would arrive unbidden.
Fields
Properties
DocumentRoot
#When a document is saved or loaded, and RetainRoot is true, the archive root node is stored here.
public Node DocumentRoot { get; }
ResolvePlugins
#Gets whether opening a file offers the user a way to fetch plugins it needs but does not have.
Deliberately separate from ReportErrors. That one governs whether a failure is shown in an error window; this one governs whether the user is asked a question. Session restore wants the second without the first — it reopens the user's own files and should certainly offer to fetch what they need, while a per-file error box at startup would be a menace.
RootFolder
#Gets or sets the root folder for Save/Open dialogs to revert to in case the file itself doesn't have a directory yet.
Window
#Gets or sets the window which functions as the parent of any Save or Open dialogs. If left unset, the Grasshopper2.UI.Editor.Instance will be used.
public Window Window { get; set; }
Methods
Examine
#Ask the user to pick a file and then examine that file in a custom browser.
public void Examine()
Examine
#Examine a specific file using a custom browser.
Export
#Execute the regular 'Save A Copy' operation on the document hosted in this DocumentIO instance. This is the fundamental save method, all other save methods ultimately call this method, while doing some additional work. This save method will not update the FileUtility.Path of the document getting saved, although it will track the save if the TrackFiles property is true.
FindScribbleTexts
#Try and harvest all scribble texts from a document file. This method will read the file, but it will not construct a new Document instance.
Returns: All scribble texts in this document.
Open
#Display the open file dialog and load the selected document.
public bool Open()
blockingList = null,
List of already loaded documents used to block a specific file from being opened.
blockingCallback = null
Optional callback in case an already loaded document is picked.
Returns: True if file was opened, false if opening failed or the loadedList prevented opening.
Open
#Open the specified file, unless it collides with one of the files in the blocking list.
Returns: True if file was opened, false if opening failed or the blockingList prevented opening.
Save
#Execute the regular 'Save' operation on the loaded document. This will either override the current file if the document is already associated with a URI, or it will open the SAVE FILE dialog.
Returns: True if the file was saved one way or another.
Save
#Execute the regular 'Save' operation on the loaded document. This will update the document's file association.
SaveAs
#Execute the regular 'Save As' operation on the loaded document. This will always show the SAVE FILE dialog, possibly anchored to the current document URI.
Returns: True if the file was saved one way or another.
SaveCopy
#Execute the regular 'Save A Copy' operation on the loaded document. This will always show the SAVE FILE dialog, possibly anchored to the current document URI, but it will not override the document URI path.
SaveCopy
#Execute the regular 'Save A Copy' operation on the document hosted in this DocumentIO instance. This is the fundamental save method, all other save methods ultimately call this method, while doing some additional work. This save method will not update the FileUtility.Path of the document getting saved, although it will track the save if the TrackFiles property is true.
ShowExportDialog
#Show the Export to Sml dialog and return the selected path.
ShowSaveDialog
#Show the Save dialog and return the selected path.
TryHarvestCanvasThumbnail
#Try and get the canvas thumbnail image stored inside a GHZ file.
Returns: Canvas thumbnail if available.