Comparing and matching list values to make a label

I’m trying to create a printable guide sheet for a layout with size and color of a tringle grid. As you can see, the size was easy, but I’m having trouble with the color designation as I can’t figure out how to match the jittered and partitioned list items back to the original list of items so I can place the value in the respective triangle.

I think what I need to do is iterate through the unaltered list, find that index in the partitioned list, then use the partition number as the color code (fed into the “C data” field of the Concatenate going into Text Tag 3D). I’ve played around with a few components like Tree Statistics, Member Set, Tree Item, but I either don’t have the right ones or haven’t figured out how to construct it properly. Bonus points if you can take that partition number and use it to write the color name in the multiline panel beside the colors.
triangle_grid.gh (34.7 KB)

the index output of Jitter is your best friend, you got very very close to the result you wanted :+1:

because you know which color corresponds to which branch, and also have the indexes of the original triangles branched by color, you can create a color-list with the very same amount of items, and synch-sort it based on the indexes

like sorting A, which is the flattened list of indexes, and together with it sorting B which is the flattened list of colors created to match it

I moved the text tag up along Z in such a way it hovers over the triangles and is readable despite the triangle previews, you can put it back once things are final

there’s a thing, you had 6 branches ready to receive colors, but only 5 colors were defined… so I added a temporary one (*see note at the very end)

this is how it looks:

going for the bonus points :slight_smile: if you prefer to have branch index (like 0, 1, 2, … 5) to identify colors, you can replace this connection here:

it will look like this, but this way it’s pretty difficult to see mistakes… so I would keep the color names until the very last second :slight_smile:

triangle_grid_inno.gh (33.9 KB)


probably this looks a bit cleaner:


triangle_grid_inno_cleaner.gh (37.1 KB)


the reason why you have those extra panels is this:

the Triangle Panels component is generating 465, but partitions are based on 450 values

if you delete this and replace the connection with the List Length, everything is gonna be alright (and you can also finally delete the extra color I had added as it’s not necessary anymore:

this is the final final final file :smiley: lots of edits… sorry for that
triangle_grid_inno_cleaner.gh (38.8 KB)


I see you’re not using those failsafes from the last thread :rofl:

Once again, you came through @inno !

The solution looks so easy and I wasn’t close at all. The Sort List component makes a lot of sense, and now I know it’s there. But I don’t understand the function of the Repeat Data component.

Thanks for the catch on the 6 color branches when their should have been 5. I think the extra amount were the half edge triangles that wouldn’t have been accounted for in the multiplication of U/V on the grid. I would never have caught it because it still assigned a color to everything so it never became apparent.

I know, I know, the failsafes :rofl:. I didn’t like not having the ability to directly change that particular percentage vs. just having it be what’s left over. Call it personal preference. I will be extra attentive to ensure it totals exactly 100%.

1 Like

Repeat Data creates a list where the input D is repeated L times, and is there just to make sure the two lists that will be sichro-sorted together are exactly identical (same number of items for each branch) otherwise the Sorting will not work

in this case, Orange gets repeated 116 times, Red 70 times and so on, in such a way that List that contains the repetition of colors mirrors the list of Jittered indexes

I get it now. Another thought just occurred to me while we are talking about matching lists. Is there a way to show how many triangles of a certain color are of each size?

well, there are many ways you can do that
if you want to ask the definition to answer “single questions” like for instance how many triangles of color #3 have height #2 you could use AND boolean gates like this:

triangle_grid_inno_final_And_bool_question.gh (43.6 KB)

but why asking for those data one-by-one when you can just retrieve the full tree with all those data at once? :smiley:

one among the many ways could be to create a first branching based on height (A) and sinch colors and geometries with that

then apply a second branching based on colors, and sinch that with the geometries (if you need those)

what you end up is a list where the path of each branch indicates:
{index_of_height ; index_of_color}

you can also use Tree Branch to retrieve geometries with a particular height and a particular color, based on their indexes (I used that to double check things were ok)

triangle_grid_inno_final_by_height_then_color.gh (43.1 KB)

This is incredible! I don’t know how you can imagine to string together these components and get this output. To know each so well that you know when they are called for, sequence them appropriately, and know what the result will be truly boggles my mind. I come from code and I would just set a counter as I iterate through a list so this kind of approach is so beyond me. I’m in awe. Thanks @inno i’m going to try and digest this now.

1 Like

I applied the technique to get the color counts by size to create the final label, but I’m missing something that gets it to iterate through the sizes.

I’ve used panels just to feed something into the Construct Path but it doesn’t iterate through the first index of the path (the A in {A,B}) to change the index for the correct size to read color counts for that size. I can’t figure out the component that would be the input.

Maybe more to the point, this doesn’t feel right, it feels hacky. Surely there is a better, cleaner, simpler, less ugly way at doing this?
triangle_grid.gh (76.1 KB)

you need to create a data tree organized the very same way you want data to flow

in this case, you want data to be organized first by Size, then by Color

so Size il leading the way, and it has (in this particular case) 5 branches:

so the target is to pass it 5 branches of data, one for each size, where the colors are not single separate entities anymore, but a single line of text

I would first concatenate B and C to get 5 branches like:
{color_0} : {amount_0}
{color_1} : {amount_1}
{color_2} : {amount_2}… and so on

then join text D on those with a comma to get one single line per branch (which is one single line per size)
{color_0: amount_0} , {color_1: amount_1}, {color_2: amount_2}… and so on

and finally concatenate those data:


triangle_grid_labels.gh (63.9 KB)

This is so insanely more elegant. Thanks again @inno . One day I might get a handle on data management.

1 Like

I watch these every night before going to sleep :smiley:

this full playlist is like the golden start point: https://www.youtube.com/watch?v=SmNPxKTDcQI&list=PL8q47GMo0JM-IdgOBe_AxkOb-B4P1u6Cc

and this is also so well structured and explained: https://www.youtube.com/watch?v=ob3ER12ut3Y

Playlist added

1 Like