Well… Then last night I also tried to find a solution, and within some hours I had the overall concept, but as usual is there always the “exception case” that ends up taking endless time. As everyone knows, one “exception case” leads to the next… and now today have I used four hours and are now down to the “exception case” where I stop, others are welcome to finalize it
My solution can randomize to the below result.
here goes the steps.

Replace empty system panels with a dummy empty panel. In the show, is it set by a grey panel, but that could be a panel there is empty. Reason for this is that you need a curtain wall with panels where the plane can be fetched.

Break the wall with the “hole” at the blue hidden line, then you have four panels that can be divided into four levels. The last wall is here where troubles begin.
Getting to this step included two python snippets…
For sorting panels: sorted along X and Y direction
lst = IN[0]
t = []
for idx, sub_list in enumerate(lst):
if sub_list[idx][3] == 0:
sub_list.sort(key=lambda k: (k[2], k[0]))
else:
sub_list.sort(key=lambda k: (k[2], k[1]))
t.append(zip(*sub_list)[4])
OUT = t
For creating random ints, where two ints are not the same AND not the same in the next line!
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
from random import choice
count_elem = IN[0]
count_max = IN[1]
divisor = IN[2]
types = []
for i in range(0, count_max):
types.append(i)
final = []
for panel in count_elem:
step = panel/divisor
if step < count_max:
step = panel
chosen = [choice(types)]
while len(chosen) < panel:
elem = choice(types)
if elem != chosen[1]:
if len(chosen) > step:
if elem != chosen[step]:
chosen.append(elem)
else:
chosen.append(elem)
final.append(chosen)
OUT = final
The “last” problem is then the last 14 elements, or to be more precise those elements marked in the red box. These elements are not sorted decent. This means that two adjacent elements can end up being the same.
In my tests, I end up in 50% of the times with two equal adjacent element where the user need to change one element… this is why I think it is a doable solution
facade_erfajo.dyn (37.6 KB)
PS. Edge elements at the sides of the hole is not included in the solution… I have not looked at those six elements.