Grasshopper Practice #01 | DataTree
Contents
- Data Combination| example
- Basic Concept of DataTree
- Components for Data Combination
- List – List Combination
- DataTree – DataTree Combination
- Data Matching | example
- Components for Data Matching
- Notation Syntax
- appendix
Data Combination
Basic Concept of DataTree
DataTree is a data system in Grasshopper and is composed of a set of containers. DataTree is a kind of hierarchical dataset and each container has an address code, which is like “{0;0;1}”, depending on its hierarchy.
Components for Data Combination
- Graft : Put each data in current container into each containers
- Flatten : Put item in each containers into one container
- Simplify : Delete all unused hierarchy from DataTree
List – List Combination
The data combination between two Lists(DataTrees with only one branch) with same number of items is quite simple. Items with same index are to be a couple.
But as for between two Lists with different numbers of items, the last item in shorter list would be couple with rest of items in longer list.
DataTree – DataTree Combination
For DataTree – DataTree Combination, the combination between Branches(containers in DataTree) is made first, then the combination between items is made in each couple of Branches.
Data Matching
Components for Data Matching
- Tree Item : Select item with certain hierarchy and index
- Path Mapper : Change Path(address of DataTree) with regular expression
- Split Tree : Split DataTree into to DataTrees with regular expression
- Relative Item : Generate a couple of DataTree to make a certain combination
Notation Syntax
To describe patterns of Path with regular expression, use following expression
- * : Any number of integers in a path
- ? : Any single integer
- 6 : Any specific integer
- !6 : Anything except a specific integer
- (2,6,7) : Any one of the specific integers in this group.
- !(2,6,7) : Anything except one of the integers in this group.
- (2 to 20) : Any integer in this range (including both 2 and 20).
- !(2 to 20) : Any integer outside this range.
- (0,2,…) : Any integer part of this infinite sequence. Sequences have to be at least two integers long, and every subsequent integer has to be bigger than the previous one (sorry, that may be a temporary limitation, don’t know yet).
- (0,2,…,48) : Any integer part of this finite sequence. You can optionally provide a single sequence limit after the three dots.
- !(3,5,…) : Any integer not part of this infinite sequence. The sequence doesn’t extend to the left, only towards the right. So this rule would select the numbers 0, 1, 2, 4, 6, 8, 10, 12 and all remaining even numbers.
- !(7,10,21,…,425) : Any integer not part of this finite sequence.
With these expression, you can describe Paths like following for example:
- {0;?}[(0,2,…)] : select all items with even index in all branches that start with 0
- {0;(0 to 3)}[!(0,3,…)] : select all items except every 3 items in branches that end in the range 0 to 3.
appendix
see this also