ObjectList

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

Properties

ActiveObjects

#
public IEnumerable<IDocumentObject> ActiveObjects { get; }
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.

AllAttributes

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

AllWires

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

AttributeBounds

#
public RectangleF AttributeBounds { get; }
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.

Attributes

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

Backwards

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

Connectivity

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

Count

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

DisabledObjects

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

EnabledObjects

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

ExpiredCount

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

ExpiredObjects

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

Forwards

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

Groups

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

PinCount

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

Pins

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

PivotBounds

#
public RectangleF PivotBounds { get; }
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.

PrimaryAndSecondary

#
public IEnumerable<IDocumentObject> PrimaryAndSecondary { get; }
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.

SelectedCount

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

SelectedObjects

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

SelectedWireCount

#
public int SelectedWireCount { get; }
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.

SelectedWires

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

SupportedPins

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

UnselectedObjects

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

Methods

Absorb

#
public int Absorb(ObjectList other, bool reinstateInputs, bool reinstateOutputs, ActionList actions = null)
Absorb all objects from another ObjectList. This eventually empties the other list completely.
other (ObjectList)List of objects to absorb.
reinstateInputs (bool)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 (bool)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 (ActionList = null)Undo action list to populate. No undo record will be added by this method.
Number of objects transferred.

Add

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

Add

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

Add

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

Add

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

AddGlobalPin

#
public bool AddGlobalPin(IPin pin)
Add a document-level pin.
pin (IPin)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

#
public void ApplyIdMap(Dictionary<Guid, Guid> map)
Apply a custom InstanceID transform to this document.
map (Dictionary<Guid, Guid>)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

#
public static void ApplyIdMap(IDocumentObject obj, Dictionary<Guid, Guid> map)
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.
obj (IDocumentObject)
map (Dictionary<Guid, Guid>)

ChangeAllIds

#
public Dictionary<Guid, Guid> 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.

ClearDisplayCaches

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

CompactMetadataDictionary

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

ContainingGroups

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

Contains

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

DeselectAllWires

#
public void DeselectAllWires()
Deselect all wires.

DeselectWire

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

DeselectWire

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

DisplayableObjects

#
public IDocumentObject[] 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.

ExpireAll

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

Find

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

FindByInlet

#
public IParameter FindByInlet(PointF point)
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.
point (PointF)Search point.
Parameter with an inlet closest to the given point.

FindByInletOrOutlet

#
public (IParameter parameter, bool inletWithinRange, bool outletWithinRange) FindByInletOrOutlet(PointF point)
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.
point (PointF)Search point.
Parameter search results or null.

FindByOutlet

#
public IParameter FindByOutlet(PointF point)
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.
point (PointF)Search point.
Parameter with an outlet closest to the given point.

FindBySearch

#
public IDocumentObject[] FindBySearch(string search, int maxResults)
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.
search (string)Search string.
maxResults (int)Maximum number of results to return.
An array of objects that match the search string best.

FindComponent

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

FindGroup

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

FindNear<T>

#
public T[] FindNear<T>(PointF locus, int maxResults, float maxDistance)
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.
locus (PointF)Search locus.
maxResults (int)Maximum number of returned results.
maxDistance (float)Maximum distance from object to locus.
Array of objects at or near the locus.

FindParameter

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

ForwardsOfT<T>

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

IsWireSelected

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

IsWireSelected

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

MetaDataSummaries

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

MetaNames

#
public IEnumerable<MetaName> 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.

MetaNamesAndValues

#
public Dictionary<MetaName, HashSet<string>> 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.

ObjectsByDrawOrder

#
public IEnumerable<IDocumentObject> ObjectsByDrawOrder(bool includeForeground, bool includeBackground)
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.
includeForeground (bool)If true, objects drawn above wires are iterated over.
includeBackground (bool)If true, objects drawn below wires are iterated over.

ReadPureObjectList

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

Remove

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

Remove

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

RemoveGlobalPin

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

RepairPins

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

ResolvePick

#
public SelectionResult ResolvePick(PointF point, bool includeGrips, bool includeForeground, bool includeBackground, bool recursive)
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.
point (PointF)Pick location.
includeGrips (bool)If true, parameter inlets and outlets will be considered.
includeForeground (bool)If true, objects drawn on top of wires will be considered.
includeBackground (bool)If true, objects drawn undernath wires will be considered. I.e. groups.
recursive (bool)If true, subobjects are considered within top-level objects.
Picking result.

SearchDownstream

#
public IEnumerable<IDocumentObject> SearchDownstream(IParameter parameter)
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.
parameter (IParameter)Parameter to start from.

SearchUpstream

#
public IEnumerable<IDocumentObject> SearchUpstream(IParameter parameter)
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.
parameter (IParameter)Parameter to start from.

SelectWire

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

SelectWire

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

ShootRay

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

Store

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

Store

#
public void Store(IWriter writer, Func<IDocumentObject, bool> filter)
Serialization method for filtered objects.
writer (IWriter)Archive writer.
filter (Func<IDocumentObject, bool>)Filter predicate.

Store

#
public static void Store(IWriter writer, IEnumerable<IDocumentObject> objects)
Serialization method for a custom list of objects.
writer (IWriter)
objects (IEnumerable<IDocumentObject>)

Store

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

WindowSelect

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

Events

ObjectAdded

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

ObjectDisplayChanged

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

ObjectEnabledChanged

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

ObjectExpired

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

ObjectInstanceIdChanged

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

ObjectLayoutChanged

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

ObjectNameChanged

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

ObjectRelevanceChanged

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

ObjectRemoved

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

ObjectSelectionChanged

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