Click or drag to resize

GH_Document Class

Represents a single Grasshopper document.
Inheritance Hierarchy
SystemObject
  Grasshopper.KernelGH_Document

Namespace:  Grasshopper.Kernel
Assembly:  Grasshopper (in Grasshopper.dll)
Syntax
public sealed class GH_Document : GH_ISerializable, 
	IDisposable, IComparable<GH_Document>, IGH_DebugDescription

The GH_Document type exposes the following members.

Constructors
  NameDescription
Public methodGH_Document
Constructor for GH_Document. Makes sure all important members are initialized.
Top
Properties
  NameDescription
Public propertyAbortRequested
Gets the abortrequested flag state.
Public propertyAttributeCount
Returns the total number of attributes in the document. Both Normal and Hidden ones
Public propertyAttributes
Returns a list of all the attributes in this document. This includes attributes for nested objects such as input or output parameters.
Public propertyAuthor
Gets the author details associated with this document.
Public propertyConstantServer
Gets the dictionary of constants defined in this document.
Public propertyContainsCustomPreviewObjects
Gets whether this document contains *any* custom preview objects.
Public propertyContainsCustomRenderObjects
Gets whether this document contains custom preview objects which are both ENABLED and included in RENDERING.
Public propertyContext
Gets or sets the context for this document. Note that the context is not a state so much as an action. Therefore it is not particularly useful to read the context after the fact, rather, context is mostly intended to be a setter, not a getter. When you set the context, all top-level document objects will be informed and the ContextChanged event will be raised.
Public propertyCustomRenderObjects
Enumerate over all enabled, rendering, non-empty custom preview objects.
Public propertyStatic memberDefaultPreviewColour
Gets or sets the default preview colour for normal objects.
Public propertyStatic memberDefaultSelectedPreviewColour
Gets or sets the default preview colour for normal objects.
Public propertyDisplayName
Gets the display name for this document. The display name is highly context sensitive and is only supposed to give the user a good idea of which document this is and whether it has been modified.
Public propertyDocumentID
Gets the document Id. The Id is assigned at construction and never changed. Note: clusters may choose to modify the Id of their internal documents.
Public propertyEnabled
Gets or sets the enabled state for this document. Enabled documents respond to events and display their previews in the Rhino viewport.
Public propertyStatic memberEnableSolutions
Gets or sets a global variable that indicates whether solutions are allowed to be recomputed. When this flag is off, the solver will be disabled and the event watchers should be silent.
Public propertyEventServer
Gets the event server that belongs to this document. The Event server may be in an inactive state, but it is never null.
Public propertyFilePath
Gets or sets the file path of this document. If the file path is not set Nothing is returned.
Public propertyIgnoredCount
Returns the total numbers of components currently in the Object Exception Ignore List.
Public propertyIsFilePathDefined
Returns True if the filename flag of this document has been set
Public propertyIsModified
Gets or sets the modified flag. If the new value differs from the old value, the ModifiedChanged() event is raised.
Public propertyModifiedSubsidiaries
Gets the number of modified subsidiary documents.
Public propertyNested
Gets or sets whether this document is nested. A nested document is always part of some other document and is therefore unknown to the DocumentServer and the Canvas.
Public propertyObjectCount
Returns the total number of top-level objects in the document.
Public propertyObjects
Returns a list of all normal, top-level objects.
Public propertyObjectSpan
Gets the total timespan for all objects.
Public propertyOwner
Gets or sets the owner of this document. A document is typically owned when it is subsidiary to some object, such as a cluster.
Public propertyPreviewBoundary
Gets or sets the preview boundary applied to this document. If a boundary has been set, only those objects which are inside the boundary will be previewed.
Public propertyPreviewBoundingBox
Gets the boundingbox used for previews.
Public propertyPreviewColour
Gets or sets the colour of unselected preview geometry.
Public propertyPreviewColourSelected
Gets or sets the colour of selected preview geometry.
Public propertyPreviewCustomMeshParameters
Gets or sets the Custom Meshing Parameters for this document, these are only used when PreviewMeshType = GH_PreviewMesh.Custom
Public propertyPreviewFilter
Gets or set the preview filter.
Public propertyPreviewMeshType
Gets or sets the preview mesh type for this document.
Public propertyPreviewMode
Gets or sets the preview display mode and makes sure the conduit instance of this class is set to match.
Public propertyProfiler
Gets or sets the profiler mode used in this document.
Public propertyProperties
The properties of this document
Public propertyRaiseEvents
If RaiseEvents is set to false, all the On....() methods of this document will stop raising events.
Public propertyRemotePanelLayout
Gets the Remote Control Panel layout for this document.
Public propertyRuntimeID
Gets the runtime ID of this document. RuntimeID is assigned once and never changed. It is also not deserialized so every document will always have a unique ID when loaded.
Public propertyScheduleDelay
Gets the delay for the next scheduled solution. If there is no solution scheduled the delay will be negative.
Public propertySelectedCount
Gets the number of selected objects
Public propertySelectionTopology
Gets the selection topology of the document.
Public propertySolutionDepth
Gets the number of nested solutions currently running. If no solutions are running, the depth should be zero. If one solution is runnnig, the depth should be one. Higher depths are only possible if a new solution was scheduled from within an existing solution with delay=0ms.
Public propertySolutionHistory
Gets a list of the last 1000 solution timespans, from oldest to youngest.
Public propertySolutionSpan
Gets the timespan for the most recent solution.
Public propertySolutionState
Gets the state of this document.
Public propertyStateServer
Gets the list of stored states in this document
Public propertyThumbnail
Gets or sets the thumbnail bitmap for this document.
Public propertyUndoServer
Gets the UndoServer instance that belongs to this document.
Public propertyUndoUtil
Gets a temporary undo utility instance that allows you to easily create standard undo events.
Public propertyValueTable
Gets the value table associated with this document.
Top
Methods
  NameDescription
Public methodActiveObjects
Returns all normal objects in the document that implement the IGH_ActiveObject interface
Public methodAddObject
Add a new object to the document. If the object is already contained, nothing will happen
Public methodAlignObjects(GH_Align, GH_Distribute)
Perform alignment and distribution logic on all selected objects.
Public methodAlignObjects(GH_Align, GH_Distribute, ListIGH_DocumentObject)
Perform alignment and distribution logic on a set of objects.
Public methodAppendToDebugLog
Useful for creating textual representations of this document for debugging purposes.
Public methodArrangeObject
Rearrange the stack order of the object.
Public methodArrangeObjects
Rearrange the stack order of a collection of objects.
Public methodAssociateWithRhinoDocument
Associate this GH_Document with the currently active Rhino document. This only works if both the 3dm and the ghx file have been saved at least once.
Public methodAutoLayoutComponents
Perform automatic layout on this document.
Public methodAutoSave(GH_AutoSaveTrigger)
Creates a new autosave file on the disk. The previous autosave file (assuming it exists) will be temporarily renamed and eventually deleted entirely. Note: AutoSave is only possible on Documents that have TopLevel Rank and a valid FilePath.
Public methodAutoSave(GH_AutoSaveTrigger, Guid)
Creates a new autosave file on the disk. The previous autosave file (assuming it exists) will be temporarily renamed and eventually deleted entirely. Note: AutoSave is only possible on Documents that have TopLevel Rank and a valid FilePath.
Public methodStatic memberAutoSaveFileName
Computes the autosave filename for a full grasshopper filepath.
Public methodBoundingBox
Returns the boundingbox of all the normal attributes. If the document contains no normal attributes an Empty RectangleF structure is returned.
Public methodBringSelectionToTop
Move the selection set to the top of the visible stack
Public methodClearIgnoreList
Clears the Object Exception Ignore List.
Public methodClearReferenceTable
Destroys the Referenced object table in the Rhino event watcher. You must call this function if you either add or remove a reference to a Rhino object.
Public methodCloseAllSubsidiaries
Iterate over all subsidiary documents and close them all without saving.
Public methodClusterInputHooks
Gets a sorted list of all the cluster input hooks.
Public methodClusterInstanceCount
Counts the number of instances of a specific cluster document ID.
Public methodClusterOutputHooks
Gets a sorted list of all the cluster output hooks.
Public methodCompareTo
Compare two documents. This function does not compare document content.
Public methodConstructDocumentTree
Create a hierarchical document tree of ownership with this document as the root.
Public methodContainsClusterHooks
Tests whether this document contains at least one cluster hook.
Public methodConvertFullNamesToNickNames
Convert all nicknames to original nicknames if they are equal to the default full name. There will be no undo record associated with this operation.
Public methodConvertNickNamesToFullNames
Convert all nicknames to full names, if they are equal to the default nickname. There will be no undo record associated with this operation.
Public methodCreateAutomaticClusterHooks
Add an input hook for every non-optional input parameter with no persistent data and no sources. Then add an output hook for every floating parameter without recipients, and for every first component output parameter where the parent component has no recipients.
Public methodCreateConnectivityDiagram
Gets the connectivity diagram for the current state of this document.
Public methodCreateExpressionParser
Create a new Expression Solver preloaded with the constants defined in this document.
Public methodDefineConstant
Add a new constant to the document. Constants are not case-sensitive, when you define a constant with an existing name, the old one will be replaced. Note: constants are as of yet unused. Eventually they are supposed to become accessible to all expressions running inside a document.
Public methodDeselectAll
Deselect all top-level attributes.
Public methodDestroyAttributeCache
Destroys the Attribute cache. Call this function whenever you do something which might affect attributes.
Public methodDestroyAutoSaveFiles
Destroys all autosave files and backup files that are associated with this document. Only call this function when you are certain that the document has been properly saved and no changes have occured since.
Public methodDestroyObjectTable
Erase the Object fast lookup table. You must call this whenever you add or remove objects to or from the document while circumventing the regular channels.
Public methodDestroyPreviewCaches
Wipe all caches for Viewport Preview logic.
Public methodDestroyPreviewMeshes
Attempts to destroy all the preview meshes in this document. It might not work for all objects, but this is still your best bet.
Public methodDestroyProxySources
Remove all remaining proxy sources from the document.
Public methodDisabledObjects
Returns all disabled objects in the document
Public methodDispose
When you discard documents you must call Dispose or the Viewport Display event handlers will not be disconnected.
Public methodStatic memberDuplicateDocument
Attempt to duplicate a document.
Public methodEnabledObjects
Returns all enabled objects in the document
Public methodExpandSelection
Grow or shift the selection set based on source and recipient links
Public methodExpirePreview
Expires the preview caches of the conduit.
Public methodExpireSolution
Expire the entire solution. This will blank all objects.
Public methodStatic memberFilterActive
Filter a list of objects.
Public methodStatic memberFilterDisabled
Filter a list of objects.
Public methodStatic memberFilterEnabled
Filter a list of objects.
Public methodStatic memberFilterInactive
Filter a list of objects.
Public methodFilterObjects(GH_Filter, GH_Filter, GH_Filter)
Returns all objects in the document that pass the filter specification
Public methodStatic memberFilterObjects(ListIGH_DocumentObject, GH_Filter, GH_Filter, GH_Filter)
Filter a list of objects using several filters at once
Public methodStatic memberFilterSelected
Filter a list of objects.
Public methodStatic memberFilterUnselected
Filter a list of objects.
Public methodFindAllDownstreamObjects(IGH_ActiveObject)
Find all objects that depend in some way on the Source.
Public methodFindAllDownstreamObjects(ListIGH_ActiveObject)
Find all objects that depend in some way on the Source collection
Public methodFindAllDownstreamObjects(IGH_ActiveObject, GH_DocumentGH_ActiveObjectFilter)
Find all objects that depend in some way on the Source.
Public methodFindAllDownstreamObjects(ListIGH_ActiveObject, GH_DocumentGH_ActiveObjectFilter)
Find all objects that depend in some way on the Source collection
Public methodFindAttribute(Guid)
Find the object that matches the ID
Public methodFindAttribute(PointF, Boolean)
Search for attributes that contain a certain point.
Public methodFindAttributeByGrip(PointF, Boolean, Int32)
Search for attributes that contain grips near the search locus
Public methodFindAttributeByGrip(PointF, Boolean, Boolean, Boolean, Int32)
Search for attributes that contain grips near the search locus
Public methodFindClusters(Guid)
Find all the clusters that have a matching ID.
Public methodFindClusters(String)
Find all the clusters that have a matching filepath.
Public methodFindComponent(Point)
Search for components that contain the locus
Public methodFindComponent(Guid)
Search for components using an ID filter
Public methodFindFloatingParameter
Search for floating parameters that contain the locus
Public methodFindInputParameter
Search for input (upstream) parameters that contain the locus
Public methodFindObject(PointF, Single)
Find the topmost object that is closest to the point
Public methodFindObject(Guid, Boolean)
Find the object that matches the ID.
Public methodFindObjectT(Guid, Boolean)
Find the object that matches the ID.
Public methodFindObjects
Find the objects in the document that match the search term. Top level object names and nicknames are searched, as well as descriptions. Some objects are special cased to allow for more targeted searches. Data descriptions are not searched.
Public methodFindOutputParameter
Search for output (downstream) parameters that contain the locus
Public methodFindParameter
Search for parameters using an ID filter
Public methodFindWireAt
Find the wire at or near the given coordinate.
Public methodForcePreview
If true, the document will draw viewport previews regardless of other conditions. Typically a document only previews if it is loaded in the canvas or when it has an RCP.
Public methodGetAllInstanceIDs
Get a sorted list of all the IGH_DocumentObject instance IDs in this document.
Public methodInactiveObjects
Returns all objects in the document that don't implement the IGH_ActiveObject interface
Public methodInvertSelection
Invert the selected state of all top-level attributes.
Public methodStatic memberIsEscapeKeyDown
Gets whether the escape key was pressed since the last time this function was called. Though in reality the actual escape state is checked no more than once every 50 milliseconds or so, which should be sufficient for a smooth user experience.
Public methodIsRenderMeshPipelineViewport
Test to see whether a pipeline should have custom render meshes vs. previews.
Public methodMergeDocument(GH_Document)
Hoist all objects from another document into this one.
Public methodMergeDocument(GH_Document, Boolean)
Hoist all objects from another document into this one.
Public methodMergeDocument(GH_Document, Boolean, Boolean)
Hoist all objects from another document into this one.
Public methodModified
Sets the modified flag of this document.
Public methodMutateAllIds
Change all the instance UUIDs of all objects in the document. Be sure to resolve all proxy sources before mutating IDs. This function will ensure all groups are updated appropriately.
Public methodNewSolution(Boolean)
Start a new solution.
Public methodNewSolution(Boolean, GH_SolutionMode)
Start a new solution.
Public methodStatic memberNonBlankFilter
This delegate can be used in the FindAllDownstreamObjects(...) methods. Only includes objects that are non-blank and non-failed.
Public methodStatic memberNullFilter
This delegate can be used in the FindAllDownstreamObjects(...) methods. Includes all objects.
Public methodOnContextChanged
Raise the ContextChanged event.
Public methodOnEnabledChanged
Raise the EnabledChanged event.
Public methodOnFilePathChanged
Raise the FilePathChanged event.
Public methodOnModifiedChanged
Raise the ModifiedChanged event
Public methodOnObjectAdded
Raise the ObjectsAdded event.
Public methodOnObjectDeleted
Raise the ObjectsDeleted event.
Public methodOnObjectsAdded
Raise the ObjectsAdded event.
Public methodOnObjectsDeleted
Raise the ObjectsDeleted event.
Public methodOnSettingsChanged
Raise the SettingsChanged event.
Public methodOnUndoStateChanged
Raise the UndoStateChanged event.
Public methodPreviewCurrentMeshParameters
Gets the currently relevant meshing parameters (do not modify the instance as it may be shared).
Public methodRead
Standard archiving function. Will deserialize the entire document.
Public methodRedo
Perform the first redo event.
Public methodRelevantObjectAtPoint(PointF)
Find the most relevant object at a given canvas location. The most relevant object might be a regular Object (Component or Parameter), it might be an attribute grip, an attribute balloon, a wire or a group.
Public methodRelevantObjectAtPoint(PointF, GH_RelevantObjectFilter)
Find the most relevant object at a given canvas location. The most relevant object might be a regular Object (Component or Parameter), it might be an attribute grip, an attribute balloon, a wire or a group.
Public methodRemoveObject(IGH_Attributes, Boolean)
Remove the top-level object in the attribute tree from the document. This method does not add an Undo event, that is the responsibility of the caller.
Public methodRemoveObject(IGH_DocumentObject, Boolean)
Remove the object from the document. This removal is the precursor to object deletion. Do not call this function if you intend to transfer the object to another GH_Document. This method does not add an Undo event, that is the responsibility of the caller.
Public methodRemoveObjects
Remove the specified objects from the document. This removal is the precursor to object deletion. Do not call this function if you intend to transfer the objects to another GH_Document. This method does not add an Undo event, that is the responsibility of the caller.
Public methodRemoveSelection
Delete all the objects in the selection set. This method does not record an Undo event, that is the responsibility of the caller.
Public methodRepairProxySources
Attempts to resolve all proxy sources in the document.
Public methodReplaceProxySources
Replace all remaining proxy sources in the document with UnresolvedProxy Objects.
Public methodRequestAbortSolution
Set the requestabort flag. The solution will be aborted whenever the current active object is completed. It is also possible that active objects themselves implement an abortion mechanism, in which case abortion might occur even sooner.
Public methodScheduleSolution(Int32)
Schedule a new solution after a specified time interval. The schedule is erased if another solution is triggered before the schedule is executed. Tight schedules override loose schedules. If this method is called during a solution, the schedule will be started after the current solution completes.
Public methodScheduleSolution(Int32, GH_DocumentGH_ScheduleDelegate)
Schedule a new solution after a specified time interval. The schedule is erased if another solution is triggered before the schedule is executed. Tight schedules override loose schedules. If this method is called during a solution, the schedule will be started after the current solution completes.
Public methodSelect(GH_RelevantObjectData)
Default pick selection behaviour. (looks at current Shift + Control modifier states to determine addition/removal)
Public methodSelect(GH_RelevantObjectData, Boolean, Boolean)
Default pick selection behaviour
Public methodSelectAll
Select all top-level attributes.
Public methodSelectedObjects
Returns all selected objects in the document
Public methodSetEnabledFlags(Boolean)
Set the enabled flags of all selected objects to true or false
Public methodSetEnabledFlags(ListIGH_DocumentObject, Boolean)
Set the enabled flags of all specified objects to true or false
Public methodSetPreviewFlags(Boolean)
Set the preview flags of all selected objects to true or false
Public methodSetPreviewFlags(ListIGH_DocumentObject, Boolean)
Set the preview flags of all specified objects to true or false
Public methodSetStatusBarEventHelper
Public methodShowPreviewSettings
Display the Preview settings dialog.
Public methodSolutionProgress
Returns the progress of the current solution.
Public methodToggleEnabledFlags
Toggle the enabled flags of all selected objects
Public methodToggleEnabledFlags(ListIGH_DocumentObject)
Toggle the enabled flags of all specified objects
Public methodTogglePreviewFlags
Toggle the preview flags of all selected objects
Public methodTogglePreviewFlags(ListIGH_DocumentObject)
Toggle the preview flags of all specified objects
Public methodToString
A document serializes itself using the filename of the current path. This is useful for sorting purposes and ListBoxes.
(Overrides ObjectToString.)
Public methodTranslateObjects
Offset objects by a certain distance in X and Y
Public methodUndo
Perform the first undo event.
Public methodUnselectedObjects
Returns all unselected objects in the document
Public methodUpdateAllSubsidiaries
Iterate over all subsidiary documents and update them with their respective owners. If a subsidiary hasn't been modified, it will not be updated and it will not be counted.
Public methodWrite(GH_IWriter)
Standard archiving function. Will serialize the entire document.
Public methodWrite(GH_IWriter, IListIGH_DocumentObject)
Special function that allows writing of a custom object list. This function is used when partial documents need to be serialized such as when exporting or during clipboard operations.
Top
Events
  NameDescription
Public eventContextChanged
The context for this document was changed.
Public eventStatic memberDefaultPreviewColourChanged
This even is raised whenever the global default for Normal preview colour is changed.
Public eventStatic memberDefaultSelectedPreviewColourChanged
This even is raised whenever the global default for Selected preview colour is changed.
Public eventEnabledChanged
The Enabled state was changed on this document.
Public eventStatic memberEnableSolutionsChanged
Raised whenever the Shared EnabledSolutions property is changed.
Public eventFilePathChanged
Raised whenever the FilePath of the document is modified.
Public eventModifiedChanged
The modified flag on the document was changed.
Public eventObjectsAdded
Raised after a collection of objects was added to the document.
Public eventObjectsDeleted
Raised after a collection of objects was removed from the document. At this point, the objects still exist, but they no longer belong to this document.
Public eventSettingsChanged
Some settings of the document were changed.
Public eventSolutionEnd
This event is raised whenever a new solution request has been handled. Even if the document is locked.
Public eventSolutionStart
This event is raised whenever a new solution is requested. Even if the document is locked.
Public eventUndoStateChanged
Raised whenever there is a change to the document undo/redo stack.
Top
Fields
  NameDescription
Public fieldStatic memberIgnoredUnknowns
A collection of missing component IDs to ignore during file load operations. Erase this cache to re-enable all the load warnings.
Public fieldStatic memberScheduleInactive
Defined the delay used to indicate the absence of a schedule.
Public fieldStatic memberScheduleRecursive
Defines the delay used to indicate the schedule should be immedate and recursive.
Top
See Also