ObjectList

References
[IoId("00000000-99c0-407b-b68e-4bd816baf526")] public class ObjectList : IStorable
Represents the collection of all objects in a document.

Properties

ActiveObjects

#
Gets a foreach enumerator for all top-level objects which are potentially active during solutions. This enumerator only considers objects whose phase is set to something other than ObjectPhase.Irrelevant.
public IEnumerable<IDocumentObject> ActiveObjects { get; }

AllAttributes

#
Gets a foreach enumerator for all primary and subsidiary object attributes.
public IEnumerable<IAttributes> AllAttributes { get; }

AllWires

#
Enumerates over all wires in this document. This includes dangling wires whose source or target parameter may no longer exist.
public IEnumerable<WireEnds> AllWires { get; }

AttributeBounds

#
Gets the strict bounds of all the top-level attributes in this document. Note that the wires which connect outputs and inputs may exceed these bounds.
public RectangleF AttributeBounds { get; }

Attributes

#
Gets a foreach enumerator for all primary object attributes.
public IEnumerable<IAttributes> Attributes { get; }

Backwards

#
Gets a foreach enumerator for all primary objects in reverse order (front to back).
public IEnumerable<IDocumentObject> Backwards { get; }

Connectivity

#
Gets the connectivity of this document. This represents an immutable snapshot of all active objects and groups and their connections.
public Connectivity Connectivity { get; }

Count

#
Gets the number of objects stored in this collection. Only primary objects are included in the count.
public int Count { get; }

DisabledObjects

#
Gets a foreach enumerator for all top-level disabled objects.
public IEnumerable<IDocumentObject> DisabledObjects { get; }

EnabledObjects

#
Gets a foreach enumerator for all top-level enabled objects.
public IEnumerable<IDocumentObject> EnabledObjects { get; }

ExpiredCount

#
Gets the number of expired and aborted objects. This only includes top-level objects.
public int ExpiredCount { get; }

ExpiredObjects

#
Gets a foreach enumerator for all top-level objects which are either expired or aborted.
public IEnumerable<IDocumentObject> ExpiredObjects { get; }

Forwards

#
Gets a foreach enumerator for all primary objects.
public IEnumerable<IDocumentObject> Forwards { get; }

Groups

#
Enumerate over all groups.
public IEnumerable<GroupObject> Groups { get; }

PinCount

#
Gets the number of document-level pins.
public int PinCount { get; }

Pins

#
Get a foreach enumerator for all document-level pins.
public IEnumerable<IPin> Pins { get; }

PivotBounds

#
Gets the strict bounds of all the top-level attribute pivots in this document. This does typically not require a layout pass and as such is a quicker and more reliable, albeit less accurate way to measure the extends of the objects.
public RectangleF PivotBounds { get; }

PrimaryAndSecondary

#
Gets a foreach enumerator for all primary and subsidiary objects. This will include those objects which are part of other objects, such as input or output parameters.
public IEnumerable<IDocumentObject> PrimaryAndSecondary { get; }

SelectedCount

#
Gets the number of selected objects. This only includes top-level objects.
public int SelectedCount { get; }

SelectedObjects

#
Gets a foreach enumerator for all top-level selected objects.
public IEnumerable<IDocumentObject> SelectedObjects { get; }

SelectedWireCount

#
Gets the number of selected wires. This count may include wires which are no longer drawn, as the list is only updated in response to UI events, not programmatic changes to the graph.
public int SelectedWireCount { get; }

SelectedWires

#
Iterate over all selected wires.
public IEnumerable<WireEnds> SelectedWires { get; }

SupportedPins

#
Iterate over all the supported pin IDs as reported by all objects in this document.
public IEnumerable<Guid> SupportedPins { get; }

UnselectedObjects

#
Gets a foreach enumerator for all top-level unselected objects.
public IEnumerable<IDocumentObject> UnselectedObjects { get; }

Methods

Absorb

#
Absorb all objects from another ObjectList. This eventually empties the other list completely.
public int Absorb(
other,
List of objects to absorb.
reinstateInputs,
If true, dangling connections from the objects in the 'other' list to sources in this collection will be reinstated. If false, those connections will be cleaned up.
reinstateOutputs,
If true, dangling connections from the objects in the 'other' list to targets in this collection will be reinstated. If false, those connections will be cleaned up.
actions = null
Undo action list to populate. No undo record will be added by this method.
)
Number of objects transferred.

Add

#
Add an object to this collection and change its instance IDs.
public bool Add(
obj,
Object to add.
idMap
Id map for keeping track of instance id changes.
)
True on success, false on failure.

Add

#
Add an object to this collection and change the instance IDs.
public bool Add(
obj,
Object to add.
PointF
location,
Hint for centre of object.
idMap
Id map for keeping track of instance id changes.
)
True on success, false on failure.

Add

#
Add an object to this collection.
public bool Add(
obj,
Object to add.
PointF
location
Hint for centre of object.
)
True on success, false on failure.

Add

#
Add an object to this collection.
public bool Add(
obj
Object to add.
)
True on success, false on failure.

AddGlobalPin

#
Add a document-level pin.
public bool AddGlobalPin(
pin
Pin to add. Pin must have no inputs, no outputs, non-empty persistent data and no pre-existing document affiliation.
)
True if pin was successfully added.

ApplyIdMap

#
Apply a custom InstanceID transform to this document.
public void ApplyIdMap(
map
A dictionary containing new object instance IDs based on old instanceIDs. It's hard to imagine you needing this function, but it's here just in case.
)

ApplyIdMap

#
Inform an object about changes to InstanceIds. You should always use this method to apply id mappings as it handles a bunch of hard-coded cases.
public static void ApplyIdMap()

ChangeAllIds

#
Mutate the instanceIds of all the objects in this document. This must be done if the objects are about to be merged into another document which may contain objects with the same IDs. The regular methods in Grasshopper (paste, merge, etc.) already do this. Never change the InstanceIDs yourself, only ever use this method to do so.
public Dictionary<Guid, Guid> ChangeAllIds()

ClearDisplayCaches

#
Clear the display caches. Caches should be updated or cleared automatically when modifying the Forwards via standard methods.
[EditorBrowsable(EditorBrowsableState.Never)] public void ClearDisplayCaches()

CompactMetadataDictionary

#
Try and compact the meta data summary by merging the value hashsets into shorter descriptions.
public void CompactMetadataDictionary(
dic
Dictionary to compact.
)
Number of entries that were compacted.

ContainingGroups

#
Iterate over all groups which (directly) contain the given instance ID. This enumerator will not return groups which contain groups which contain the object.
public IEnumerable<GroupObject> ContainingGroups(
objectId
)

Contains

#
Test whether an instanceId is defined in this collection.
public bool Contains(
instanceId,
InstanceId to search for.
level
Object levels to include in search.
)
True if the instanceId is already defined in this collection.

DeselectAllWires

#
Deselect all wires.
public void DeselectAllWires()

DeselectWire

#
Deselect a specific wire.
public bool DeselectWire(
source,
Source parameter ID.
target
Target parameter ID.
)

DeselectWire

#
Deselect a specific wire.
public bool DeselectWire(
wire
Wire description.
)

DisplayableObjects

#
Gets all display capable objects in this document, regardless of states and properties. *If* an object can draw displays, it will be included in this collection. This array is cached, calling this method repeatedly should be fine from a performance point of view.
public IDocumentObject[] DisplayableObjects()

ExpireAll

#
Expire all objects in this collection.
public void ExpireAll()

Find

#
Find the object with the given instanceID.
public IDocumentObject Find(
instanceId
Instance id to look for.
)
Object or null.

FindByInlet

#
Find the parameter with the inlet closest to the search point. This method will find an inlet even if it is occluded by another object.
public IParameter FindByInlet(
PointF
point
Search point.
)
Parameter with an inlet closest to the given point.

FindByInletOrOutlet

#
Find the parameter with an inlet or outlet closest to the search point. This method wil not return inlets or outlets which are occluded by other objects.
public (IParameter parameter, bool inletWithinRange, bool outletWithinRange) FindByInletOrOutlet(
PointF
point
Search point.
)
Parameter search results or null.

FindByOutlet

#
Find the parameter with the outlet closest to the search point. This method will find an outlet even if it is occluded by another object.
public IParameter FindByOutlet(
PointF
point
Search point.
)
Parameter with an outlet closest to the given point.

FindBySearch

#
Find the objects that match the search string. UNFINISHED METHOD. I need to figure out what fields to search and what the notation might look like.
public IDocumentObject[] FindBySearch(
search,
Search string.
maxResults
Maximum number of results to return.
)
An array of objects that match the search string best.

FindComponent

#
Find the component with the given instanceID.
public Component FindComponent(
instanceId
Instance id to look for.
)
Component or null.

FindGroup

#
Find the group with the given instanceID.
public GroupObject FindGroup(
instanceId
Instance id to look for.
)
Group or null.

FindNear<T>

#
Find all objects at the given location, sorted from most relevant to least relevant. Objects in front of other objects are more relevant, and objects closer to the locus are also more relevant.
public T[] FindNear<T>(
PointF
locus,
Search locus.
maxResults,
Maximum number of returned results.
maxDistance
Maximum distance from object to locus.
)
Array of objects at or near the locus.

FindParameter

#
Find the parameter with the given instanceID.
public IParameter FindParameter(
instanceId
Instance id to look for.
)
Parameter or null.

ForwardsOfT<T>

#
Iterate over all top-level objects and return those which are of the specified type.
public IEnumerable<T> ForwardsOfT<T>()

IsWireSelected

#
Gets whether a specific connection is considered selected.
public bool IsWireSelected(
source,
Source parameter ID.
target
Target parameter ID.
)
True if the wire between them (if any) is considered selected.

IsWireSelected

#
Gets whether a specific connection is considered selected.
public bool IsWireSelected(
wire
Wire description.
)
True if the wire between them (if any) is considered selected.

MetaDataSummaries

#
Get the meta data summaries of the current object set.
public MetaDataSummary MetaDataSummaries()

MetaNames

#
Enumerate over all meta names used in this document. Note that meta names may change during every solution. This method will iterate over all objects regardless of whether new solutions are happening while it's busy.
public IEnumerable<MetaName> MetaNames()

MetaNamesAndValues

#
Find all meta names and associated values. Note that meta names may change during every solution. This method will iterate over all objects regardless of whether new solutions are happening while it's busy.
public Dictionary<MetaName, HashSet<string>> MetaNamesAndValues()

ObjectsByDrawOrder

#
Enumerate over all objects in the (reverse) order in which they are drawn. That is, the first object returned is the topmost one, and so on. The draw order is a fairly complicated one since the introduction of Pins, which can be attached to objects with different draw-order and even different draw-layer.
public IEnumerable<IDocumentObject> ObjectsByDrawOrder(
includeForeground,
If true, objects drawn above wires are iterated over.
includeBackground
If true, objects drawn below wires are iterated over.
)

ReadPureObjectList

#
Read a list of objects without any other context.
public static IEnumerable<IDocumentObject> ReadPureObjectList(
reader
)

Remove

#
Remove an object from this collection.
public bool Remove(
objectId
InstanceId of object to remove.
)
True on success, false on failure.

Remove

#
Remove an object from this collection.
public bool Remove(
obj
Object to remove.
)
True on success, false on failure.

RemoveGlobalPin

#
Remove the pin with the given type id.
public bool RemoveGlobalPin(
pinType
)

RepairPins

#
Perform a set of pin/cushion repair methods.
public (PinRepair method, Guid pin, Guid cushion)[] RepairPins(
repairMethods = PinRepair.Default
)
Array of repair actions taken.

ResolvePick

#
Resolve the target of a pick operation on all the objects in this document. Note that this will not include any wires, as the shapes of wires aren't known to the document. Only the Canvas which draws the document knows where and how wires are drawn so if you want a pick which includes the wires, you must use the Canvas.ResolvePick() method instead.
public SelectionResult ResolvePick(
PointF
point,
Pick location.
includeGrips,
If true, parameter inlets and outlets will be considered.
includeForeground,
If true, objects drawn on top of wires will be considered.
includeBackground,
If true, objects drawn undernath wires will be considered. I.e. groups.
recursive
If true, subobjects are considered within top-level objects.
)
Picking result.

SearchDownstream

#
Iterate over all objects that are downstream from a parameter. This includes the component if the parameter is an input, it will include all target parameters, their components, the outputs of those components, and so on. This a depth-first search without duplicates.
public IEnumerable<IDocumentObject> SearchDownstream(
parameter
Parameter to start from.
)

SearchUpstream

#
Iterate over all objects that are upstream from a parameter. This includes the component if the parameter is an output, it will include all source parameters, their components, the inputs of those components, and so on. This a depth-first search without duplicates.
public IEnumerable<IDocumentObject> SearchUpstream(
parameter
Parameter to start from.
)

SelectWire

#
Select a specific wire.
public bool SelectWire(
source,
Source parameter ID.
target
Target parameter ID.
)

SelectWire

#
Select a specific wire.
public bool SelectWire(
wire
Wire description.
)

ShootRay

#
Shoot a ray through the display geometry of all objects and see which one is hit.
public bool ShootRay()
True if ray hit something.

Store

#
Serialization method with custom contents.
public void Store(
writer,
contents
)

Store

#
Serialization method for filtered objects.
public void Store(
writer,
Archive writer.
filter
Filter predicate.
)

Store

#
Serialization method for a custom list of objects.
public static void Store()

Store

#
Serialization method. Write all objects in this collection.
public void Store(
writer
)
Store

WindowSelect

#
Perform a window selection on all objects and wires.
public SelectionResult WindowSelect(
window,
mode,
considerForeground = true,
considerBackground = true,
considerWires = true
)
Number of modified selection states.

Events

ObjectAdded

#
This event will be raised after an object has been added to this collection.
public event EventHandler<AfterAddObjectEventArgs> ObjectAdded

ObjectDisplayChanged

#
Raised whenever the display state of one of the objects in this collection expires.
public event EventHandler<ObjectEventArgs> ObjectDisplayChanged

ObjectEnabledChanged

#
Raised whenever one of the objects in this collection changes its enabled state.
public event EventHandler<ObjectEventArgs> ObjectEnabledChanged

ObjectExpired

#
Raised whenever one of the objects in this collection expires.
public event EventHandler<ObjectEventArgs> ObjectExpired

ObjectInstanceIdChanged

#
Raised whenever the instance ID of one of theobjects in this collection expires.
public event EventHandler<ObjectGuidEventArgs> ObjectInstanceIdChanged

ObjectLayoutChanged

#
Raised whenever the layout of one of the objects in this collection expires.
public event EventHandler<ObjectEventArgs> ObjectLayoutChanged

ObjectNameChanged

#
Raised whenever one of the objects in this collection changes its name.
public event EventHandler<ObjectNameEventArgs> ObjectNameChanged

ObjectRelevanceChanged

#
Raised whenever one of the objects in this collection changes its auxiliary state.
public event EventHandler<ObjectEventArgs> ObjectRelevanceChanged

ObjectRemoved

#
This event will be raised after an object has been removed from this collection.
public event EventHandler<AfterRemoveObjectEventArgs> ObjectRemoved

ObjectSelectionChanged

#
Raised whenever one of the objects in this collection changes its selected state.
public event EventHandler<ObjectEventArgs> ObjectSelectionChanged