# Document class

Namespace: [Grasshopper2.Doc](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.doc.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public class Document : IStorable
```

The Grasshopper document class. Documents contain all objects, undo record, solution and display logic.

## Constructors

- [Document](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/ctor.md): Deserialization constructor.

## Finalizer

- [~Document](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/finalize.md): Destructor, this will remove the document from the static global database.

## Properties

- [AllDocuments](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/alldocuments.md): (static) Provides an enumerable list of all [Document](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document.md) instances currently still in memory. Documents constructed during the execution of this enumeration will not appear, however documents currently awaiting garbage collection may.
- [Animations](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/animations.md): Gets the animation server for this document. The server owns the named animations stored in the file, and runs them.
- [CustomValues](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/customvalues.md): Provides an object for storing named custom values that survive file io.
- [Dependencies](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/dependencies.md): Gets the dependencies for this document. I.e. which other documents are required for input data.
- [Display](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/display.md): Gets the display properties for this document.
- [File](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/file.md): Gets the file accessor for this document.
- [Globals](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/globals.md): Gets the globals repository for this document.
- [Hash](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/hash.md): 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](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/identity.md): 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](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/isempty.md): 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.
- [Methods](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/methods.md): Gets the actions utility.
- [Modifications](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/modifications.md): Gets the number of modification since the last save.
- [Modified](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/modified.md): 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.
- [NamedViews](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/namedviews.md): Gets the named view collection of this document.
- [Notes](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/notes.md): Gets or sets the notes on this document. Notes are stored inside the [Document.CustomValues](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/customvalues.md) object under the [StandardKeys.UserNotes](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.standardkeys/usernotes.md) key.
- [Objects](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/objects.md): Gets the collection of all objects contained within this document.
- [Parent](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/parent.md): 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](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/projection.md): 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.
- [Solution](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/solution.md): Provides access to solution related methods for this document.
- [State](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/state.md): Gets or sets the state of the current document.
- [Undo](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/undo.md): Gets the undo/redo stack for this document.
- [ViewportDragging](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/viewportdragging.md): Gets or sets whether shapes in persistent data can be dragged in the viewports while this document is loaded in the canvas. Changing this does not modify the document.

## Methods

- [Close](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/close.md): Close this document and release all resources and event handlers. After calling this method, no other method should be called.
- [Modify](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/modify.md): Increment the modification counter on this document.
- [NewActiveDocument](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/newactivedocument.md): (static) Create a new empty, [DocumentState.Active](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.documentstate.md) document.
- [NewInactiveDocument](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/newinactivedocument.md): (static) Create a new empty, [DocumentState.Inactive](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.documentstate.md) document.
- [NewInertDocument](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/newinertdocument.md): (static) Create a new empty, [DocumentState.Inert](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.documentstate.md) document. Inert documents have their [Document.Display](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/display.md) property set to false.
- [Store](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/store.md): (2 overloads) Write the data inside this document to a writer.
- [ToString](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/tostring.md)
- [Unmodify](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/unmodify.md): 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.

## Events

- [ModifiedChanged](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/modifiedchanged.md): This event is raised whenever the modified flag of this document changes.
- [ParentChanged](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/parentchanged.md)
- [StateChanged](https://developer.rhino3d.com/api/gh2/type/grasshopper2.doc.document/statechanged.md): This event will be raised whenever the document state changes.
