Document
ReferencesThe Grasshopper document class. Documents contain all objects, undo record, solution and display logic.
Constructors
Finalizer
Properties
AllDocuments
#Provides an enumerable list of all Document instances currently still in memory. Documents constructed during the execution of this enumeration will not appear, however documents currently awaiting garbage collection may.
Animations
#Gets the animation server for this document. The server owns the named animations stored in the file, and runs them.
Dependencies
#Gets the dependencies for this document. I.e. which other documents are required for input data.
Hash
#Gets the ID associated with this document. This can be a very expensive property to call as it will involve computing a hash of the entire document contents. The hash is cached locally, but wiped whenever the document is modified. Note that the hashing does *not* include undo records, canvas and viewport imagery, or plugin data. However it does include all objects (including all their persistent values), all custom values, and all named views.
Identity
#Gets the runtime identity of this document. Assigned in the constructor, stable for the lifetime of the in-memory document, and not serialised to disk. Used primarily to name autosave files of unnamed documents so that successive autosaves overwrite the same file. The setter is internal and is intended only for session-restore code that needs to reattach a previously persisted identity to a freshly constructed document.
IsEmpty
#Gets whether this document is considered empty and not worth saving or keeping. An empty doc must have no objects, no undo records, no file path and no custom values.
Modified
#Gets whether this document has been modified in any way since the last save. This property just checks to see if the number of Modifications is larger than zero.
Notes
#Gets or sets the notes on this document. Notes are stored inside the CustomValues object under the StandardKeys.UserNotes key.
Parent
#Gets or sets the parent document of this document. Note that this property is not (and indeed cannot) be serialized as part of file IO, so it must be assigned anew, ideally prior to each solution.
Projection
#Gets the projection details of this document within the canvas. Zoom values less than or equal to zero indicate an unset projection. When documents with unset projections are loaded into a canvas, they will be automatically centred.
Methods
Close
#public void Close()
Close this document and release all resources and event handlers. After calling this method, no other method should be called.
NewInertDocument
#Create a new empty, DocumentState.Inert document. Inert documents have their Display property set to false.
Store
#Write the data inside this document to a writer.
Parameters:
| writer (IWriter) | |
| contents (FileContents) |
Unmodify
#public void Unmodify()
Set the modification count to zero. This happens automatically on save. You should only call this function if there are changes you *don't* want the user to save.