Click or drag to resize

DataTreeT Class

Implements basic Grasshopper Data Tree functionality in an easy-to-use class. This class is used primarily in Scripting components. If you're using the Grasshopper SDK you should consider using the GH_StructureT class instead.
Inheritance Hierarchy
SystemObject
  GrasshopperDataTreeT

Namespace:  Grasshopper
Assembly:  Grasshopper (in Grasshopper.dll)
Syntax
public class DataTree<T> : IGH_DataTree

Type Parameters

T
Data type of this class.

The DataTreeT type exposes the following members.

Constructors
  NameDescription
Public methodDataTreeT
Default constructor, create an empty data tree.
Public methodDataTreeT(DataTreeT)
Create a shallow duplicate of another data tree. This means it will create a new tree that contains the same items.
Public methodDataTreeT(DataTreeT, DataTreeTDuplicateT)
Create a true duplicate of another data tree.
Public methodDataTreeT(IEnumerableT, GH_Path)
Create a tree with a single branch
Top
Properties
  NameDescription
Public propertyBranchCount
Gets the number of branches defined in this tree.
Public propertyBranches
Gets a list of all the data-arrays in this tree
Public propertyDataCount
Gets the total number of data items (including nulls) stored in all branches.
Public propertyItem
Gets or set the data item at the specified path and index.
Public propertyPaths
Gets a list of all the branch paths in this tree.
Public propertyTopologyDescription
Gets a description of the topology of the tree. Useful for debugging purposes.
Top
Methods
  NameDescription
Public methodAdd(T)
Add (append) a data item to the last branch in the tree. If no branches exist yet, a new one will be created with [path = {0}]
Public methodAdd(T, GH_Path)
Add (append) a data item to the specified branch in the tree. If the branch doesn't exist yet, it will be created.
Public methodAddRange(IEnumerableT)
Add (append) a list of data items to the last branch in the tree. If no branch exists yet, a new one will be created.
Public methodAddRange(IEnumerableT, GH_Path)
Add (append) a list of data items to the specified branch in the tree. If the branch doesn't exist yet, it will be created.
Public methodAllData
Collects all data in the tree in a single list. Does not alter the topology of this tree.
Public methodBranch(GH_Path)
Gets the list of data which belongs to a given Branch path.
Public methodBranch(Int32)
Gets the list of data which belongs to the branch path at the given index.
Public methodBranch(Int32)
Gets the list of data which belongs to a given Branch path.
Public methodClear
Clears the entire tree.
Public methodClearData
Removes all data from all branches without affecting the tree topology.
Public methodEnsurePath(GH_Path)
Create a new branch with the specified path if it doesn't already exists.
Public methodEnsurePath(Int32)
Create a new branch with the specified path if it doesn't already exists.
Public methodFlatten
Flattens the entire tree into a single path.
Public methodGraft(Boolean)
Graft all paths in this tree. "Grafting" means appending a new branch for every item in an existing branch.
Public methodGraft(GH_Path, Boolean)
Graft a single path in the tree. "Grafting" means appending a new branch for every item in an existing branch.
Public methodInsert
Insert a data item to the specified branch in the tree. If the branch doesn't exist yet, it will be created.
Public methodItemExists
Test if the specified path + item index are defined inside the tree.
Public methodMergeTree
Merges two trees together. Data inside similar branches will be merged into single lists and unique paths will be appended. The other tree will not be altered, so beware that data is now shared among both trees.
Public methodPath
Gets the data path at the specified index.
Public methodPathExists(GH_Path)
Test if the specified path is already defined inside the tree.
Public methodPathExists(Int32)
Test if the specified path is already defined inside the tree.
Public methodRemovePath(GH_Path)
Removes a path and all associated data from the structure. If the path doesn't exist, nothing will happen.
Public methodRemovePath(Int32)
Removes a path and all associated data from the structure. If the path doesn't exist, nothing will happen.
Public methodRenumberPaths
Renumber all paths in this data tree, using a single incrementing path index.
Public methodRenumberPaths(String)
Renumber all paths in this data tree, using a single incrementing path index.
Public methodSimplifyPaths
Simplify the branches in this tree by removing all identical path entries. The length of the shortest path will be indicative of the similarity search depth. If this tree only contains a single branch, the branch wil be simplified to its last index.
Public methodToString
Creates a brief description of the tree.
(Overrides ObjectToString.)
Public methodTrimExcess
Trims the excess allocated memory in all branches
Top
See Also