Random.list and adjacent families

Hi @Nick_Boyts and @JacobSmall

I think your solution works quite well for a single organized grid but when it comes to a randomly generated wall it might fall short.
Using boundingbox and intersections I’ve captured the adjacent panels for each panel in the building in question. Though I might need the last push over the edge, so if you still think it might be fun please have a go :slight_smile:

Below is how I see the problem:

Currenlty I get my output as:
{{4,7},{3,4,6,7},{4,6},{1,5,8},{0,1,2},{3,7},{1,2,8},{0,1,5},{3,6},{3,10},{5,9}}
Where each list’s index corresponds to the panel and the content of the list is the adjacent panels.

Looking forward to see if you can tackle this one! :wink:

My initial thought was less about finding the exact panels and more about generating the values - let the user worry about selection. As such, with my method the actual wall geometry is irrelevant. I’ll try and post some later which illustrates.

1 Like

It’s true that my code only works for orthogonal grids but I think you could get it to work with varying row lengths just by adding a try loop.

try:
     panelBelow = rowBelow[p]
except:
     panelBelow = None

I think the important part (in my solution at least) is maintaining a list of adjacent geometries and/or their colors. As long as you’re assigning values one panel at a time, you can always retrieve the adjacent panels and query their color. Any panel without a color (None) won’t hurt anything when comparing against your list of available colors.

1 Like

I think the simplicity of your solution is quite nice! And must admit that the solution I suppose is quite a bit heavier.
Though If panels are not organised by a continuous list of adjacent panels (grouped by rows) it will unfortunately not work, this is why I’m trying to utilize the geometry and find the intersecting panels and using this as the “sorting” criteria.

This is definitely a more inclusive approach. Unfortunately it probably comes down to geometry intersection. However, with simple panel geometry it might not be a big deal. You could take your current panel and filter for all other intersecting (coincident) geometry. Take the assigned colors from the adjacent panels (again, None values are fine here, and expected) and compare them to your list of available colors. Now you have your list of allowable colors for the current panel and you just have to randomly select one.

That indeed is the plan, though I do not see it as a linear problem, as you are iterating over the bars:

for bar in bars
if barcolor in adjacentbarcolor
set barcolor random (Not same color)
else
pass

Though if I change the color of bar 1 based on the colors of bar 4 and 5 and I have to change the color of bar 4 caused by bar 7, then the color 1 is no longer valid. I might be over-complicating the issue. I simply find the problem quite interesting though challenging.

Edit: Let me rephrase that for clarity.

You need to check all adjacent panels at once to avoid that problem. You can’t assign a color based on one adjacent panel then hope that you don’t run into issues later on. If you use the actual panel geometry or a single perimeter curve this should be straight forward. A single panel (in this example) can have up to 4 adjacent panels, however no more than 2 will ever have colors assigned as they’re being checked for the current panel.

1 Like

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 :slight_smile:

My solution can randomize to the below result.

here goes the steps.

  1. 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.

  2. 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 :slight_smile:

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.

6 Likes