algorithmic modeling for Rhino
hello,
im new to grasshopper so please bear with me...
I have a list created by duplicating items {0;0;0;0} N=95 and I can figure out a way of splitting the list into 19 branches each with 5 itmes say {0;0;0;0 -1, 2... 19 ) N=5
i know is basic but im still trying to get my head around lists/trees and how to manipulate them properly
thanks for your time
sn
Tags:
Here is one way. Although if the list of data isn't evenly divisible by the # of desired items per branch (in your case 5) then the remainder of data is left out.
Probably isn't the best way but it will work for what you want.
This version will include the remaining data when the list length of the duplicated data isn't evenly divisible by the number of desired items per group.
If you have 87 items and want groups of 5, it will give you 17 groups of 5 and 1 group of 2.
Have you seen these components, they are much easier. Less thinking more doing.
http://www.grasshopper3d.com/profiles/blogs/tree8-list-management-c...
Michael's right, I just checked these out - way cool.
You will want the AllocN component with the number 5 plugged into the N input.
Will be using them from now on.
made so many of my definitions neater.
Thanks Brian,
I tried to write down the logic of the operation so I could replicate it later, if you have 5 mins I'll appreciate if you can have a glance:
1 get the lenght of duplicated data (one branch, xno items in one list)
2 divide the list lenght value by the numer of items per branch needed
3A generate a list with the series component: the step equal to the target numer of items per branch; the no of items equals the number of target branches
3B generate a list with the series component: the first number of the series equals to the number of items needed (-1 to account for the 0 index); the step size again equal to the target number of itmes per branch as 3A
4 feed 3A & 3B to a domain component thus identifying the start -3A- and end -3B- of the domains by which the list will be subdivided
5 use a subset component with the domains above thus creating 19 branches with lists having 5 items each
for lists which are subdivided into branches when the target number of branches is not a multiple of the number of items contained in the list:
6 identify if the target number of branches is a multiple of the list by using the modulus component fed by the list lenght -1- and the target number of branches
7 identify last index in the 3B series with the item component (reversed to take the last value fed)
8 add 6+7 above which dill define the start of the domain that will pick up the remanent items not accommodated in 5
9 add (+1) to 7 above to define the end of the domain that will pick up the the remanent items not accommodated in 5
10 feed 8 & 9 to a domain component
11 include 10 as part of the subset in 5
I'm now trying to understand the components mentioned by Michael...
sn
Hi sono man, if I understand you correctly - hope I do -
you could open the User Object I made some time ago to see how I did this. I posted it in this discussion. The tree8 version is way faster, but I can't say how to view that code... Hope this helps anyway.
Hello Pieter,
thanks, and yes, you got it.
Is interesting as operations are reduced in your object, quite neat.
I just have one query (please be aware im new to gh), I'm not quite sure what the filter component is doing. If you have a sec it will be appreciated.
sn
The filter component just takes a boolean input (true or false, 0 or 1) and only passes through the corresponding data. When true (or 1) is input to the G input of Filter, the data connected to the 1 input will be output. When false (or 0) is input only the data going into input 0 will be output.
In this case it just allows the user the option of whether or not to cull the remnant data (if there is any).
I should note that I hadn't looked at pieter's definition until now - it's quite clean and simple as well. Very nice.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by