Sort or Call Specific Branches

This is my first post to the forum! So I hope my question is relatively clear and correctly tagged. Let me know if any other content would be helpful in solving this problem too.

I have been working with branches & lists in grasshopper to move data. Each branch and its associated list data carry a brep and may carry points. Essentially, all I want to do is sort or call specific branches and move them to a bin. Given that I am moving several branches with specific indices and with associates information, I want to call a branch with a specific branch identifier. The reason I am doing this is because I have a hexagon grid that has been extruded and booleaned and now want to bucket the all the nth hexagons or nth hexagon sides, but those sides have other attached information such as points when applicable and I don’t want to loose the side’s specific index code either.

For example: if I have multiple branches like {3;3;0}, {3;3;1}, {3;4;0}, {3;4;1}, {3;4;2}, {3;4;3}…{11;2;0}, {11;2;1}, {11;2;2}… I would want to call all the branches that end in 0 and bucket them like {#;#;0} so {3;3;0}, {3;4;0}…{11;2;0}…and with them their associated list data. Likewise call all branches that are defined by the location 3;4 {3;4;#} (indicating that it is an object defined by row 3 and column 4) so branch {3;4;0}, {3;4;1}, {3;4;2}, and {3;4;3} or more accurately to call branches having the same first 2 keys (all 3;4s, 11;2s or another pair) and bucket those branches. So all the 3;3;#s get placed into a bucket, all 3;4;#s bucket, all 4;3;#s bucket, ect.

I have tried path mapper, cull, & list item components with no luck as seen in the attached file. Hopefully attaching those helps show where I’m aiming. I assume the best way might be in python. I am starting to learn python so would actually prefer to resolve the issue in there if possible anyway. Plus, I might try to continue in python for later steps such as joining. If there is a way to do it in python that’d be great; although, if there is a way to do this in grasshopper, I would be curious to know what I could have done too.

Thanks in advance for taking a look!

2020_0403_BinSorting& (1.2 MB)

Sounds like what you need is Split Tree.

2020_0403_BinSorting& (1.1 MB)

1 Like

Hi HS_Kim. This works great for just 6 buckets, so thanks! I’m realizing though that while this will work for part of the case above, I don’t think it will work for the full future case I have to solve.

In the future, I’ll have to bucket all branches by the first two numbers. For example, branch {3;4;0} (brep at the 0th place in hexagon at row=3 col=4) and branch {3;4;1} (brep at the 1st place in hexagon at row=3 col=4) would go in a bucket together and so on. Using the process you mentioned, I’d have to create a component for each row/col combination. There are too many row/col combinations to feasibly do this, and furthermore, the number of row/cols is dynamic. Ideally my solution would work for arbitrary row/col layouts, so I was hoping to use a component or python that could be configured to bucket branches in a more dynamic way. In this case, I want to bucket by the first two numbers in the branch definition {x;y;z} so by x and y.

If I understand you right, you could use Shift Paths along withSplit Tree


That certainly helped. Thank you! Although, I seem to still have issues retaining information related to specific sides {#;#;(0-5)}.

Ultimately my goal is to unroll like in the attached image (updated in the .gh) however there are some unrolled pieces that in the future I would need to shift and realign so that they might be joined to single breps. The sides result from an unrolled hexagon (6 sides) although some hexagons are open faced hexagons meaning they have fewer than 6 sides.

The grey image attached shows how it is unrolling currently and the red image shows how I will need it to unroll before I shift it (the third one shifts/moves to match properly to the other side) to form a final joined singular brep.

If I can keep the individual side data then I could essentially check whether sides/breps are present or not and shift the faces accordingly. In the 3rd red unroll, there is space in the center so I would need to shift the breps to one side. Also, since sides will be denoted male (odd 0,2,4) and female (even 1,3,5), placement matters, which is why I need to maintain the side # (the {#;#;(0-5)} path layout). Using that data I need to shift the sides as seen in the updated 3rd unroll from the current output (the grey image) so that the breps can be joined, but position is maintained.

I think I would need bins in python so I could say given that the list is full with 6 sides, skip, vs if the list contains side numbers 0,1,2,4,and 5 and those bins combination contain values, I could move 4 and 5 over to the 0 side and consequently shift the whole brep by a length of 2 unit side widths since I moved the 2 sides (the 4 and 5 side) to re-position the final unrolled brep.

Likewise, if a list contains side number 0,1,2, and 5 I could move 5 over to the 0 side and still consequently shift the whole brep by a length of 2 units widths since male/female or (odd/even) location matters.

I updated a few things in the .gh file to hopefully better show where I am headed. After going through your comments/sample, it definitely seemed to resolve part of my problem or offer a cleaner way to move head and get me further! Although once I can better manipulate the paths, I know I’ll be set; but unfortunately, I still seem to be having difficultly preserving data and being able to compare and cross check since there seems to be a lot of variability.

2020_0403_BinSorting& (1.2 MB)