How to link random panels considering some criterias?

Hello world !
I really need some help with this code.
I have flat rectangular panels on a facade done with the relative item component.
Using the random component, I separate randomly 4 types of panels. A color for each.
After that I would like to link them verticaly, I mean create bigger panels with a maximum of 3 panels linked but I don’t know how to proceed ?
I tried to use the point group comp to make groups of their centers according to a given distance but nothing convincing.
After linking verticaly the panels, I would like to ling them horizontaly with a maximum of 6 panels…
Please help me guys, i’m really struggling with thios code…
Thanks in advance.

random (25.8 KB)

Do you mean something like that by saying “link verically” and “link horizontally”?
random (29.9 KB)

Thank you for your time Dfytz1.
But I mean to link them by colors… First verticaly and in a second time horizontaly…
I’ll send a picture soon to show my problem

Please give some examples on how to link them vertically/horizontally.
I tried to understand it, but I think your description is not clear enough.

so that’s what we have in gh

and that’s the result i’m looking for
Uploading: result.jpg…

1 Like

1: I got the vertical logic:
for each column, merge as much panel as possible, lets say from top to bottom, and 3 panel max.
if there are 5 panel together it will be merged into 2 panels (3+2), is that right?
2: for the horizontal logic, it is not clear even with your example picture.

3: there are some panels not merged, not sure about the reason

4: your request is difficult to achieve in GH. For a single vertical logic, it is possible, but if stacked with horizontal one, native components will be hard, some code may be needed. In this case I think you’d better merge them manually.

random (31.9 KB)
the easiest way possible

and a bit more control over panelig
random (37.9 KB)