GH_DocumentIO

public sealed class GH_DocumentIO
Provides basic IO operations for GH_Documents.

Constructors

GH_DocumentIO

#
Create a new instance of GH_DocumentIO without an internal document.
public GH_DocumentIO()

GH_DocumentIO

#
Create a new instance of GH_DocumentIO with an internal document.
public GH_DocumentIO(
internal_doc
Document to internalise.
)

Properties

DisableOverwriteProtection

#
Gets or sets whether the file overwrite protection dialog ought to be shown during risky saves.
public static bool DisableOverwriteProtection { get; set; }

Document

#
Gets or sets the internal document.
public GH_Document Document { get; set; }

IsDocument

#
Gets a value indicating whether or not this instance of GH_DocumentIO contains an internal document.
public bool IsDocument { get; }

LocalClipboardContent

#
Gets the contents of the local clipboard.
public string LocalClipboardContent { get; set; }

Methods

ClearClipboard

#
Clear the Clipboard Text content. This function wipes both the Text and UnicodeText clipboard fields.
public void ClearClipboard()

Copy

#
Copy the internal document into the clipboard.
public bool Copy(
clipboard,
Specifies the clipboard type to use.
limitToSelection
If true, only the selected objects will be copied.
)
True on success, false on failure.

Copy

#
Copy the specified objects in the internal document into the clipboard.
public bool Copy(
clipboard,
Specifies the clipboard type to use.
guids
List of object ids to copy.
)
True on success, false on failure.

Copy

#
Copy the internal document into the clipboard.
public bool Copy(
clipboard
Specifies the clipboard type to use.
)

GetDocumentIcon

#
Try and extract the icon image of a document. Not all gh/ghx files contain an icon so this function may return null. The document itself is not loaded and rendered, so the icon really has to be part of the file already.
public static Bitmap GetDocumentIcon(
filePath,
Filepath to examine.
Size
size
)
An icon bitmap on success or null on failure. Caller is responsible for disposing of the image.

GetDocumentThumbnail

#
Try and extract the preview image of a document. Not all gh/ghx files contain a thumbnail so this function may return null. The document itself is not loaded and rendered, so the thumbnail really has to be part of the file already.
public static Bitmap GetDocumentThumbnail(
filePath
Filepath to examine.
)
A preview bitmap on success or null on failure. Caller is responsible for disposing of the image.

Open

#
Perform a default Open operation and store the result as the internal document.
public bool Open()
True on success, false on failure.

Open

#
Open the file at the given location.
public bool Open(
filePath
Path of Grasshopper file to open.
)
True on success, false on failure.

OpenDocumentDialog

#
Display the Open GH/GHX dialog.
public string OpenDocumentDialog(
path = null,
Optional default path.
title = "Open…"
Title of dialog.
)
FileName specified via the Open dialog or null if the dialog was cancelled.

Paste

#
Deserialize a Grasshopper document from the clipboard. On success, the internal document of this GH_DocumentIO instance will be set.
public bool Paste(
clipboard
Specifies the clipboard type to use.
)
True on success, false on failure.

Save

#
Perform a default Save operation on the internal document.
public bool Save()
True on success, false on failure.

SaveAs

#
Perform a default Save As operation on the internal document.
public bool SaveAs()
True on success, false on failure.

SaveAsCopyDocumentDialog

#
Display the Save As Copy GH/GHX dialog.
public string SaveAsCopyDocumentDialog(
path = null
Optional default path.
)
FileName specified via the Save As Copy dialog or null if the dialog was cancelled.

SaveAsDocumentDialog

#
Display the Save As GH/GHX dialog.
public string SaveAsDocumentDialog(
path = null
Optional default path.
)
FileName specified via the Save As dialog or null if the dialog was cancelled.

SaveBackup

#
Save a time-stamped copy of the current file.
public bool SaveBackup()
True on success, false on failure.

SaveDocumentDialog

#
Display the Save GH/GHX dialog.
public string SaveDocumentDialog(
path = null,
Optional default path.
title = "Save…"
Title of dialog.
)
FileName specified via the Save dialog or null if the dialog was cancelled.

SaveQuiet

#
Quietly save a file to a given location.
public bool SaveQuiet(
path
)
True on success, false on failure.

ShowOverwriteDialog

#
public static int ShowOverwriteDialog(
filename,
lastSave,
fileOnDisk
)

ShowOverwriteDialog

#
public static int ShowOverwriteDialog(
filename
)

SubsidiaryDocumentSavePrompt

#
Display a 'stuff has changed do you want to save' message box with Yes/No/Cancel options.
public static DialogResult SubsidiaryDocumentSavePrompt(
document
Top level document.
)
Yes, No, Cancel or None state.

SubsidiaryDocumentSavePrompt

#
Display a 'stuff has changed do you want to save' message box with Yes/No/Cancel options.
public static DialogResult SubsidiaryDocumentSavePrompt(
documentName,
Name of top level document.
modified,
Boolean indicating whether top-level document is modified.
modifiedSubsidiaries
Number of modified subsidiary documents.
)
Yes, No, Cancel or None state.