DocumentMethods

References
public class DocumentMethods
This class exposes common operations that are performed on documents. Always consider using a method in this class instead of a more low-level one.

Methods

AddDependency

#
Add a listen object with a specific dependency to this document at the given location.
public Listen AddDependency(
PointF
location,
Location for Listen object.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Listen instance if successful.

AddDependency

#
Add a dependency via an already constructed Listen object.
public void AddDependency(
PointF
location,
listen,
actions = null
)

CanCreateChain

#
Gets whether the specified objects can be turned into a chain.
public bool CanCreateChain(
objects,
out string
whyNot
)

CanCreateCluster

#
Gets whether the specified objects can be turned into a cluster.
public bool CanCreateCluster(
objects,
out string
whyNot
)

ChainObjects

#
Attempt to chain a set of objects. Only consecutively selected components which are connected only to their neighbours can be chained.
public Chain ChainObjects(
objects,
Objects to chain.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Created chain or null.

ChainSelection

#
Attempt to chain the current selection. Only consecutively selected components which are connected only to their neighbours can be chained.
public Chain ChainSelection(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

ClusterObjects

#
public IDocumentObject ClusterObjects(
objects,
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

ClusterSelection

#
Move all selected objects into a cluster. A cluster operation requires that the selection topology is either singleton or convex. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public IDocumentObject ClusterSelection(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The created cluster or null if no cluster could be created.

CopySelection

#
Perform a copy to clipboard operation on the selected objects.
public bool CopySelection(
clipboard
Clipboard type. This method does not allow for ClipboardKind.Instance clipboards. If you want instance clipboards, you must use your own DocumentIO instance.
)
True if this method successfully changed the document state.

CutSelection

#
Perform a cut to clipboard operation on the selected objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public bool CutSelection(
clipboard,
actions = null
)
True if this method successfully changed the document state.

DeleteObjectData

#
Delete all persistent data in all specified objects.
public int DeleteObjectData(
objects = null,
actions = null
)
Number of objects whose persistent data was deleted.

DeleteObjects

#
Delete all specified objects. Note that deletion completely isolates objects from their neighbours. As such, the objects are not really fit to be inserted into a different document afterwards.
public int DeleteObjects(
objects = null,
wires = null,
actions = null
)
Number of deleted objects.

DeleteSelection

#
Delete all selected objects and wires.
public int DeleteSelection(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Number of deleted objects and wires.

DeleteSelectionData

#
Delete all persiustent data in all selected objects.
public int DeleteSelectionData(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Number of object whose persistent data was deleted.

DeselectAll

#
Deselect all objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int DeselectAll()
The number of objects whose states was changed.

DisableObjects

#
Disables all specified objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int DisableObjects(
objects,
actions = null
)
The number of objects whose states was changed.

DisableSelected

#
Disables all objects in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int DisableSelected(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of objects whose states was changed.

DropObject

#
Add an undoable object at the specified location.
public bool DropObject(
(Guid id, string init)
obj,
Object id of object and optional initialisation code.
PointF
location,
Location cue.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

DropObject

#
Add an undoable object at the specified location.
public bool DropObject(
obj,
Object id of object.
PointF
location,
Location cue.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

DropObject

#
Add an existing undoable object at a specific location.
public bool DropObject(
obj,
Object instance to add.
PointF
location,
Location cue.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

DropObject

#
Add an existing undoable object at a specific location.
public bool DropObject(
obj,
Object instance to add.
PointF
location,
Location cue.
sourceCue,
If supplied and sensible, the new object will be connected to this source parameter.
targetCue,
If supplied and sensible, the new object will be connected to this target parameter.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

DropSnippet

#
Add an undoable snippet at a specific location.
public bool DropSnippet(
snippet,
Snippet to add.
PointF
location,
Location cue.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

EnableObjects

#
Enables all specified objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int EnableObjects(
objects,
actions = null
)
The number of objects whose states was changed.

EnableSelected

#
Enables all objects in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int EnableSelected(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of objects whose states was changed.

GroupObjects

#
Put all supplied objects into a group.
public GroupObject GroupObjects(
objects,
name = null,
colour = null,
actions = null
)
A group containing the selected objects, or null if there was no selection.

GroupSelection

#
Put all selected objects into a named group. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public GroupObject GroupSelection(
name = null,
Group name to assign.
colour = null,
Optional colour override.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
A group containing the selected objects, or null if there was no selection.

GrowSelection

#
Grow the selection one level to the left and/or right. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int GrowSelection(
upstream,
If true, sources to the current selection will be included.
downstream
If true, recipients to the current selection will be included.
)
The number of objects whose states was changed.

HideObjects

#
Disables the display of all specified objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int HideObjects(
objects,
Objects to show.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Number of objects whose state was changed.

HideSelected

#
Disables the display of all objects in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int HideSelected(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of objects whose states was changed.

HideSelectedInputs

#
Disables the display of all input parameters in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int HideSelectedInputs(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of inputs whose states was changed.

HideSelectedOutputs

#
Disables the display of all output parameters in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int HideSelectedOutputs(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of outputs whose states was changed.

InvertSelection

#
Invert the selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int InvertSelection()
The number of objects whose states was changed.

IsolateObject

#
Isolate an object. Note that this method modifies the document state without adding any undo record. If you wish to isolate objects in an undo-able fashion, you should use the Document.Methods class instead.
public void IsolateObject(
obj,
pins,
inputs,
outputs,
actions = null
)

IsolateObject

#
Isolate an object. Note that this method modifies the document state without adding any undo record. If you wish to isolate objects in an undo-able fashion, you should use the Document.Methods class instead.
public void IsolateObject(
obj,
pins,
inputs,
outputs,
omit,
actions = null
)

MakeRoom

#
Make room in the document by inflating a rectangle from the to the dimensions and moving nearby objects away to avoid overlaps. Each displaced object retains, at most, the spacing it had to its (original) neighbour before the expansion; this is capped at the horizontal/vertical alignment gap from SnappingSettings.Current. Objects strictly to the left of before are never moved.
public void MakeRoom(
RectangleF
before,
The initial space taken up by the growing space.
RectangleF
after,
The final grown space.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

MigrateObjects

#
Add a list of objects (possibly from another document) to this document. The objects will be removed from the other document without any undo records. InstanceIDs will be changed if they conflict with objects already in this document.
public Dictionary<Guid, Guid> MigrateObjects(
objects,
Object to add.
PointF
location,
Centre of compound bounds.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
A instance ID map encoding all instance ID changes.

MoveSelection

#
Move all selected objects.
public int MoveSelection(
xOffset,
Number of units to move to the left. Negative offsets move to the right.
yOffset
Number of units to move down. Negative offsets move up.
)
The number of objects whose states was changed.

PasteFromClipboard

#
Perform a paste from clipboard operation. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public bool PasteFromClipboard(
clipboard,
behaviour,
actions = null
)
True if this method successfully changed the document state.

PasteGrasshopper1XmlFromClipboard

#
Try and paste the Grasshopper 1.0 xml archive on the OS clipboard into the document. Objects with dedicated migrators are converted, components without one become interop components, and the wires among the pasted objects are preserved.
public bool PasteGrasshopper1XmlFromClipboard(
actions = null
)
True on success, false on failure.

RestorePlaceholders

#
Replace every placeholder in this document whose original object can now be deserialised, typically because a missing plugin was just installed. This includes the placeholders inside clusters hosted by this document, at any nesting depth. Placeholders which still fail to deserialise are left alone; they lose nothing and may succeed on a later attempt. Instance ids are stable across each swap, so the wires of surviving neighbours need no repair.
public int RestorePlaceholders(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Number of restored objects, including those inside clusters.

SelectAll

#
Select all objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int SelectAll()
The number of objects whose states was changed.

SetColourOverrideObjects

#
Set the display colour override from all specified objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int SetColourOverrideObjects(
objects,
Objects to override.
colour = null,
Colour override, or leave null to clear the colour override.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of objects whose states was changed.

SetColourOverrideSelected

#
Set the display colour override on all selected objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int SetColourOverrideSelected(
colour = null,
Colour override, or leave null to clear the colour override.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of objects whose states was changed.

ShiftSelection

#
Shift the selection one level to the left or right. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int ShiftSelection(
upstream
If true, sources to the current selection will be selected.
)
The number of objects whose states was changed.

ShowDependencyGraph

#
Show the dependency graph leading up to this document in a modal dialog. If this document has no dependencies this method returns immediately.
public void ShowDependencyGraph()

ShowObjects

#
Enables the display of all specified objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int ShowObjects(
objects,
Objects to show.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Number of objects whose state was changed.

ShowSelected

#
Enables the display of all objects in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int ShowSelected(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of objects whose states was changed.

ShowSelectedInputs

#
Enables the display of all input parameters in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int ShowSelectedInputs(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of inputs whose states was changed.

ShowSelectedOutputs

#
Enables the display of all output parameters in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int ShowSelectedOutputs(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of outputs whose states was changed.

SplitWire

#
Insert a Shout+Listen pair into an existing wire.
public bool SplitWire(
source,
Source parameter.
target,
Target parameter.
name,
Name of shout object.
PointF
location,
Location for insertion.
out Shout
shout,
Newly created shout object.
out Listen
listen,
Newly created listen object.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)

ToggleDisplayObjects

#
Toggle the display of all specified objects. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int ToggleDisplayObjects(
objects,
Objects to show.
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
Number of objects whose state was changed.

ToggleDisplaySelected

#
Toggle the display of all objects in the current selection. Note that this method does not cause a new solution, nor any viewport or canvas updates.
public int ToggleDisplaySelected(
actions = null
Optional list of undo actions to populate. If null, an undo record will be added.
)
The number of objects whose states was changed.