Grasshopper Tutorial 08 | List Manipulation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
alright so this video I would like to talk about manipulating lists so we already talked about how we can create lists but there are lots and lots of ways of manipulating lists or building up upon lists and I would just like to show you a few of those options the first thing I would like to show you is how to duplicate data alright so let's say we have this list but what we actually want to have is this sequence of numbers repeated several times and then you can take this duplicate block plug in the data and then just tell it how many times it's supposed to repeat it so by default this is too and it will simply duplicate that list we have here from zero to eight over to here and plug it in behind and if we tell to do it three times course we at three lists there is an interesting option here which says retain list order and if I use a toggle switch to change that false you can see that it actually it previously was like this where it will take the first list and then stick it on the the back of it again we do that's false it will take that first item copy it twice second night and copy it twice and so forth now another thing you can do just going to leave this is we can repeat data and this takes data and then a target length so this I this list right now has got five entries so I'm just going to tell it that I want to have a list of 12 entries and it will repeat my original list as many times as needed to get those 12 items so we'll only have half a list of the original or two fifths of the original list here at the end and we can do this too arbitrary length right just two ways to take a basic input of a list and then repeat that as many times as you need so what would like to now show you requires a few points I'm going to take the input of this list to construct some points so I'm going to plug these values into the x value and by doing that we're going to get this list of points which move along the X direction and I'm going to do that twice but I'm going to give the second one a y-coordinate five whoops there we go and now I'm going to connect these with a polyline and I put in the yield I get a straight line connecting the bottom the bottom points and I can now take the other set of points shift and then it will attach those lists together all right so I've got one list and i'm attaching a second list to that and putting it in here and it creates a list with ten entries and puts the polyline through all of it now I can do this with shift but at some sage it as soon as you plug in more than two and the order of those different data streams comes important it's usually a good idea to use the merge block so i can actually do the same thing by putting these two here and then it automatically adds another one for a third data stream and then plug the polyline into the back of that and we get the same result all right now let's say I don't want to simply attach these two lists and to end or all end to start but I want to alternate between these two well for that we can use a weave so and what the weave does is it takes two lists and weaves them together with a certain pattern so the four pattern is take one from the zero list and then one from the one list and then repeat that pattern until we've exhausted both lists so if I now plug this into the polyline what will get its this so it's taken one from the bottom then one from the top bottom top bottom top top and I'm now going to create a panel to change this pattern so right now the pattern looks like this all right remember to right click and then go on multi-line data so this won't change anything is still the same pattern let's say we want to have it the other way round two ways of doing that we can actually just double click here and change those values or we can go right click and say reverse and then it will go in the other direction now personally I think it's nicer to simply change these values here because then it's more visible and easier to understand for somebody reading your code and let's do a different pattern the pattern doesn't have to be only too long we can create patterns of arbitrary length so let's go 0 1 1 0 and let's loop that and then we get something like this so it's going 0 1 1 0 starting again from the beginning so 0 1 1 0 0 1 and then it would go on one again and so forth now so far we've talked about combining entries from multiple lists let's now talk about kicking items out of a list this is called culling and for that I'm going to hide all of this and go back to our paneled wall here we go you there we get there so let's say I want to remove some of these let's call them stories out of the array put a few more here okay that's six now there's different ways of culling and I'm going to go through a few of them so I'm first going to start with cul m and what this does is it takes a list and then it culls it takes a certain frequency so the default is to so every second entry in the list is going to be removed so if we hide this you can see that actually this looks more easy to understand so it will now remove every second entry on that list and it will repeat that no matter how long that list is and we can change that to be three for example okay three if you don't want to have this bead actually a parameter that you change but you want it to be something a little bit more starting in your program is usually also a nice idea to use a panel instead and just go three if that's slightly smaller and then plug it in that way is more obvious that you don't want to frequently change the value so yes that's the first way of culling things now second way of killing things is using a pattern so just as before we plug in the list and then we give it a pattern and the default pattern is false false true true so this false and true is called a boolean so it's something that's only got two states and these two stay can either be described as false and true or you can use zero and one doesn't matter so if we want to create our own pattern we can once again go into our panel and say 001 okay go to multi-line data okay put that in and then you can see that it only keeps every third item right and we can use the pattern we used before 01 10 and then it will kick out the first one keep to pick out one start again kick-out one keep two and so forth now if you don't want to have something that repeats regularly you're going to have to start culling individual indices so the same way we can get access to a list item by using the the list item command and giving it indexed we can also call things with an index so let's kick this out and then go to cull index I'm going to put the list here and then let's say I want to remove the the first row which would be then index zero and then maybe the fourth one which is then index 3 because we always start counting at zero and then also that one there we go put those in here we go so we kick out the index zero and then index three and four now here's a cool thing see how the counting always starts at zero we can also count backwards and in this case the last entry of a list will have the index of minus one so if i type in here minus one and then minus three e minus four it'll remove the last item in the list and then the third to last item and the fourth last item there you go so that's just a few ways to manipulate data repeat lists and then use indices to remove items from lists or patterns to remove or merge different data entries of the list thank you for watching
Info
Channel: Individualized Production in Architecture
Views: 13,756
Rating: 4.9797978 out of 5
Keywords:
Id: 03K5e0KwQh8
Channel Id: undefined
Length: 11min 48sec (708 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.