public sealed class Pins : IStorable
Class for maintaining all pins stuck into a cushion.

Constructors

Pins

#
public Pins(IDocumentObject docObject, IReader reader)
Deserialisation constructor.
docObject (IDocumentObject)Parent object. Must also implement the IPinCushion interface.
reader (IReader)Deserialisation reader.

Pins

#
public Pins(IDocumentObject docObject)
Create a new pin collection.
docObject (IDocumentObject)Parent object. Must also implement the IPinCushion interface.

Properties

Above

#
public IEnumerable<IPin> Above { get; }
Enumerate upwards over all the pins above this object.

AboveAndBelow

#
public IEnumerable<IPin> AboveAndBelow { get; }
Enumerate over both the above and the below pins.

AboveCount

#
public int AboveCount { get; }
Gets the number of pins stuck to the top of the object.

Below

#
public IEnumerable<IPin> Below { get; }
Enumerate downwards over all the pins below this object.

BelowCount

#
public int BelowCount { get; }
Gets the number of pins stuck to the bottom of the object.

Count

#
public int Count { get; }
Gets the total number of pins in this collection.

Object

#
public IDocumentObject Object { get; }
Gets the object this collection is associated with. The instance is guaranteed to implement the IPinCushion interface.

PinsAndIndices

#
public IEnumerable<(IPin pin, int index)> PinsAndIndices { get; }
Enumerate over all pins and their indices.

Indexers

this[]

#
public Guid this[int index] { get; }
Pin InstanceId for the pin at the given index.
index (int)

Methods

BothAgree

#
public static bool BothAgree(IPin pin, IDocumentObject obj)
Gets whether both the pin and the object agree that they belong together. Note that if this method returns false, the objects are not in a valid state. Although it probably doesn't stop Grasshopper from solving the document, it is nevertheless a serious issue.
pin (IPin)
obj (IDocumentObject)

CanBeAttachedTo

#
public static bool CanBeAttachedTo(IPin pin, IDocumentObject obj)
Test whether a specific pin can be attached to a given object. This method will test not just whether the association is in principle allowed, but also whether there's room for the given pin.
pin (IPin)Pin.
obj (IDocumentObject)Potential object.
True if pin and object are compatible and available. This method returns true even if the specified pin is already attached to the object.

FindObject

#
public static IDocumentObject FindObject(IPin pin, Document document = null)
Find the object (if any) into which the given pin is stuck.
pin (IPin)Pin for object search.
document (Document = null)Document override. If not specified, the pin document is used instead.
Object containing the given pin, or null.

GetInsertionSlots

#
public static IEnumerable<(RectangleF box, int index)> GetInsertionSlots(IDocumentObject obj, IPin pin)
Enumerate over all pinning slots for an object.
obj (IDocumentObject)Object to iterate over.
pin (IPin)Optional pin for filtering.

GetPin

#
public void GetPin(Guid pinId, out IParameter pin)
Find the most relevant pin which affects the object which owns this Pins instance. Note that this method also searches groups which wrap this object, as well as parent documents which host this document.
pinId (Guid)Id of pin to find.
pin (out IParameter)Found pin.

GetTree

#
public bool GetTree(Solution solution, Guid pinId, out IParameter pin, out ITree tree)
Find the most relevant instance of a pin of the given type and return its volatile data.
solution (Solution)Solution within which this request happens.
pinId (Guid)Id of pin to find.
pin (out IParameter)Parameter (i.e. pin) which was found.
tree (out ITree)Volatile data tree.
True if a pin was found and it has a tree.

GetTree<T>

#
public bool GetTree<T>(Solution solution, Guid pinId, out IParameter<T> pin, out Tree<T> tree)
Find the most relevant instance of a pin of the given type and return its volatile data.
solution (Solution)Solution within which this request happens.
pinId (Guid)Id of pin to find.
pin (out IParameter<T>)Parameter (i.e. pin) which was found.
tree (out Tree<T>)Volatile data tree.
True if a pin was found and it has a tree.

IsCompatibleWith

#
public static bool IsCompatibleWith(IPin pin, IDocumentObject obj)
Tests whether a pin can in principle be attached to the given object.
pin (IPin)Pin.
obj (IDocumentObject)Potential object.
True if object and pin are compatible.

IsPinned

#
public bool IsPinned(Guid pinTypeId, out int index)
Test whether a pin with the given type id is attached to this object.
pinTypeId (Guid)The pin type id to search for.
index (out int)The pinning index if found.
True if a pin with the given type id is stuck in this object.

IsPinned

#
public bool IsPinned(IPin pin, out int index)
Test whether a specific pin is attached to this collection.
pin (IPin)
index (out int)

Pin

#
public static bool Pin(IPin pin, IDocumentObject obj, int index, ActionList undo)
Stick a pin into the given object at the given pinning index. This method also removes the pin from any object it is currently stuck into.
pin (IPin)
obj (IDocumentObject)
index (int)
undo (ActionList)
True if a change was made which requires a new solution. All objects involved will be expired by this method.

ResolvePins

#
public IParameter[] ResolvePins()
Find all pins which affect the object which owns this Pins instance. This is limited to only those pins which are supported by the object. Note that this method also collects pins attached to groups which wrap this object, as well as any parent documents.

Store

#
public void Store(IWriter writer)
writer (IWriter)
Store

Unpin

#
public static bool Unpin(IPin pin, ActionList undo)
Detach a pin from whatever object it is attached to.
pin (IPin)
undo (ActionList)
True if the pin was actually removed.

Events

PinAdded

#
public event EventHandler<PinEventArgs> PinAdded
Raised after a pin was added to this collection.

PinRemoved

#
public event EventHandler<PinEventArgs> PinRemoved
Raised after a pin is removed from this collection.