Grasshopper Tutorial 11 | Trees and Flatten

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
alright let us now look at trees in grasshopper we've encountered them before and I've pulled up this script where we extruded this kind of facade like structure now just to walk through it once more start with a line and then we divide that and this is where you could see that if you put in a single value in grasshopper you get a solid line and if you then get a list of values you get this double line so let's look at that I've another panel so we took him took one line and divided it and so now we've got a series of T values which we then plug into this shatter to get the individual line segments right now we then extruded that and created a linear array and when we created that linear array we got a new connection type this dashed line which indicates that it is a tree but what does that mean well if we give any object in grasshopper a list it'll operate on the items of that list now if you connect this a set of points a list of points to a polyline block you will get a single polyline but if you connected to a block like a linear array it'll operate on every single item in that list in this case our curves and create a linear array of each entry in that list so if we look at what comes out the other side we now have a list of lists so for every item in our original list which we plugged into this linear array it has created a new list with the number of items that were supposed to create in that array so we've got four segments here at each of those four segments we now have a separate list with three entries each and untrimmed surface in here so actually I'll connect it here to the extrudes for that you can see you put in these four untrim surfaces and now we've got this structure which has got four entries in it with three entrances in each of it so we bought this list of lists now if we now take this list of lists and do a deep rep and look at the four corner points of every single one of these surfaces you can see that the same thing goes on so now what we've got is one list for every four corner points and if you look at these it these indices at the top you see if something has changed so right now we've got four entries and this you know kind of seems intuitive at the end if you ignore the the first three zeros because they all say the same the the address of each of these lists goes zero one two three so it's kind of like we had you know if we want to access something in a list we give it the index well now we've got a list of Lists so every list needs to have an index as well now you can see that the two last numbers are changing because now we've actually got a list of lists of lists because for each of these three untrim surfaces we've now got the four points and you can probably tell line out that talking of lists of lists of lists gets a little bit confusing in some stage so the metal or the metaphor for this in grasshopper is a tree and that will become obvious as soon as we take a look at the parameter item block here we go so let's plug in this output of this linear array in here you can see that it says okay I've got four branches and each of these branches has got three items in it so instead of talking of a list of Lists we're talking about a tree and this tree has got four branches and on each of these branches so on leaf the leaf in this case is a list we've got three items and we can actually go right click on the parameter and say draw a tree and then we'll get this graphical representation so you can see we've got four branches one for each of these surfaces and then this orange thing is the list at the end of that tree now if we connect the same block to ah points we see that okay now we've got a tree with twelve branches and each of them has got four points in it at the end and it's list but if we draw the tree you can see that it's got this hierarchy so the higher code we reach the hierarchy which we expect here so we've got first of all we've got our individual surfaces then we've got let's say our stories and within each of these stories we then have the panels which have then got the four points well that's reflected here all right so we've got four columns so each of those columns as a branch and then on those columns we've got three rows so these three stories and each of those of the branch and then at the end of that we've got the lists with the four points in it now the reason why there's these two let's say trunks of the tree behind each other is that grasshopper works very cleanly so each time it does certain operations it will add another layer to that tree and you can see that here if we go to the beginning of our program we begin with this divide you can see that here we've already introduced and you layer to that tree right so in the beginning we had a list with which was a it was simply a list there was no further levels here but as soon as we did this it added another level now each of these levels still only had one entry right there's only one branch behind each other if you look at the parent viewer for this and draw the tree you can see that it's a straight line all the way to the list there's only one tree trunk but as soon as we continue we continue adding layers even though it might not cause the tree to branch it adds this not the tree trunk level just to keep things tidy and logical within itself all right we can actually remove these unnecessary tree trunks if we like it might be useful at certain stages you can simply right click and then go simplify and then you can see that tree trunk disappears and we've only got the pertinent branches and all of these commands which we're going to talk about including the simplify are available where is it here sets there we go under the tree and you can see simplified tree actually got this nice little icon where you can obviously see that it's going to delete the the trunk of that tree all right so that just to understand trees so far whenever we've encountered a tree we've usually told you to flatten it so to get rid of the tree and turn it back into a list so what does that mean and I prepared a little something here and this might seem familiar if you've ever looked at the book algorithm aided design by arturo Tedeschi I've taken a few of the examples from that book as inspiration for these tutorials so what I have here is a linear array of triangular surfaces now if I deconstruct these and then look at the points so I'm going to take these points and put them as a separate object just so that we can look only at the points all right so now we've got these points and we look at it in a panel you can see already by the dashed line that this is a tree so for each triangle there's a separate list so each triangle is on a separate branch now if we connect these with a polyline what will happen is that it will operate on every list separately so if we plug this in you can see that draws a polyline between those three points for every one of these lists so we've got a tree and each branch is one triangle and at the end of that branch is a list with the points in it and so what grasshopper does is it executes this block on every single branch and not over all of the items in one go now if we wanted to have that so let's say we want to have a line going through all of these points we simply have to flatten the tree so I'm actually going to connect a power M viewer as well so that we can look at both at the same time there we go got our tree now what happens when I right click and go flatten is that all those branches disappear it gets turned into a single flat list and then that means that the polyline goes through all of the points and once again this command is also available here in or is it there Latin tree nice little tree stuff okay now an example where we had to use flatten was when we were splitting a surface right so I've got this barrel-like surface here and was created with a sweep we've divided two of the defining lines the rail and the section curve and use these to create the UV coordinates to create the lines with which we want to split this surface now if you look at the output of this line you can see that I've already flattened it and what happens when I understand it so let's remove this and remove this and you can see that now instead of having a list of curves which we want to split this we've got a set of branches and each of these branches has got a list with only one entry at its end and what that means is that this surface split block splits the original surface once with this curve once there's that curve once with that curve instead of using all the curves at the same time and this becomes very obviously obvious as soon as you bake it because now you can see that it's done one split there and it's done another split along another line all right so maybe that is something that you want to do at some stage and we'll talk about that in the next video but in this case we obviously don't want to do it because we don't want to have a split operation for every single curve separately we want to have them all together so what we do is we flatten both of these trees so that we've got two lists we merged them into this command and then what happens is that it actually does a single split operation using all of these lines and creates the 100 surfaces that we would expect if we use a divide with a count of 10 in both directions alright so we talked a little bit in detail what the tree is so it's a list of lists of lists grasshopper will the grass of a blocks will work on the lists passed to it so the entries on the list I was critical so if you want to have the block operates separately you give it a bunch of branches each with its own list at the end but if you want to combine everything at the end of that you need to flatten the tree so that you get a single list so that it uses all the data in one go and not in separate instances alright thank you for watching
Info
Channel: Individualized Production in Architecture
Views: 9,288
Rating: 4.970149 out of 5
Keywords: Grasshopper, RWTH
Id: MCxo0WWneC4
Channel Id: undefined
Length: 13min 29sec (809 seconds)
Published: Thu Nov 17 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.