Template:Grasshopper list editing

From TOI-Pedia

List editing

Grasshopper uses, in contrast to a programming environment, no object names to define an object. This may sound trivial but it one of the most fundamental differences from a traditional modelling environment. In Grasshopper the object or objects are placed in a list. The different lists of data are organized in a data tree structure where every branch and data content of the branch have an index number. Accessing the object is therefore more problematic then in a scripting environment. Grasshopper has various tools to remedy this problem. These tools supports the editing and selecting the content of the lists. Knowledge of these techniques are essential for the effective use of Grasshopper.

Data tree structure

Multiple data will be stored in a data tree. The data tree is the hierarchical organization of the data. Each branch of the tree can contain data. What makes it tricky is the fact that some actions like loft uses only the data content of a single branch whilst the creation of a line the data uses from two of the same branches of two different data trees. To make it even more complex the data of different level branches can't interact. In some case the whole data structure will be collapsed or reorganized to let the data correctly interact with other data. A sound knowledge of list editing is therefore crucial to effectively use Grasshopper.


For example if we generate a space frame which is based on a surface, we have to edit the list of the various components on several occasions and we have to take in account on which branch what data is stored. This organization of data will influence the use and selection of components. The component which generates a polyline will work in one data structure and not in another. The same with for example the component line. The way the component handles the input list or lists can differ quite substantially. There are two main approaches on how the component handles the input structure.


Option 1

  • The first is the component will work only on the data on the same branch within the same tree. For example a Polyline uses the data of serie of points on a single branch to define the polyline. So from the content of a branch a polyline is generated and therefore for each branch 1 polyline. There is only 1 input channel for the points needed to define the polyline. Another example is the Loft component. It also uses only 1 channel for curve input.


However when we use 2 input lists of curves into the Loft component the Loft component will combine the curves on the same branches but of different trees into curves on the branch of a single tree. The trees are merged and the data is placed on similar branches. This will work if there are more then 1 curves defined on the resulting branches.


If however the data structure is not similar because there are additional branches in one list, the data won't be combined and handled as separate lists. So getting the data on the right level of branches can be one prerequisite of a successful merger of data.


Option 2

  • The second option is the use of a component which needs multiple inputs. An example is the line.The line needs 2 points. If a data tree structure is offered as data input for 1 of the two points the content of each point on the branch is seen as a separate input. This point will interact with a point of the same branch in the other data tree. The fundamental difference with the first option is that you always need two inputs and therefore two data structures which will interact on the same branch level.


In the example we can see a difference of the amount of points on the branch of one input and the amount of the other branch of input. In one tree structure the amount of points defined on a branch is 4 in the other tree structure 1. Grasshopper will generate in this case a line from one point of the four from one list to the 1 of the other list. It will then generate a line from the second point of the four to again the 1 in the other list, and so on. If all the four points are calculated , Grasshopper switches to a new branch and start calculating the lines between the four point and the single point of the other list. The lines therefore have a similar end point per branch. The way the lists are combined is depending on which option is selected in the option menu of the component.


The List.

List creation and editing forms a crucial role in the functionality of Grasshopper. The list is the organization of multiple data in a data tree which is the result of the action or definition of the parameter/s. In the case of the loft, we can define, for example, 3 curves and place them all together in 1 parameter. This parameter will contain and therefore has an output of 3 curves. These curves are placed in a list. The component (action) of loft will have an input of the 3 curves and will make a loft between the 3 curves. If we however want to add two tubes to the edge of the surface we only need two curves of that list. So we have to extract only the two edge curves from the list and ignore the middle one. To make this possible Grasshopper provides us with a range of list editing tools. They can be found under the tab of Sets. Understanding these list editing tools is crucial for understanding Grasshopper. In the case of the loft we can use the Cull Index component ( action) to tell the computer to ignore the second curve of the list. By defining the index number of the curve , in this case 1 ( index curves 0,1,2) the middle one this curve will be ignored by the action of creating pipes.

Cull index.jpg

List editing can be quite complex because the data is not only listed with an index number but can also be defined in various levels. This will be discussed later.


In contrast to scripting the objects you create in Grasshopper don't have their own name. They are part of a list , where the object is identified with an index number. Accessing the object is therefore more problematic then in a scripting environment. This is further complicated by the structure of the lists in different data branches. This structure will be further explained later.


Personal tools