Random.list and adjacent families

We have a curtain wall facade with smaller elements. We have 6 different families to fit into the elements. We have in dynamo made a randomizer for the different families but we would like not to have two of the same family next to each other (horizontal and vertical). How do we do that?

Please show is your work so far. :slight_smile: And maybe a quick graphic of what it is that your wish to achieve.

I’m a new user so it looks like i cannot upload anything

A dropbox-link or drive-link is quite fine :slight_smile:

https://drive.google.com/drive/folders/1aVzOKhoDfdLedW7Ru9HhdChJXR39K16x?usp=sharing

Is there any kind of logic to the placement of the panels prior to your randomization (in the order that they are loaded) so that you that way can distinguish the placement of the panels, as to not get the types next to each other?

Alternatively you can attempt to play with the boundingbox and intersect nodes to try and sort your panels of building 127 to not be next to each other. :slight_smile:

Unfortunately I cannot do any testing as I would need the .rvt file with the families loaded :slight_smile:

Iterating over each entire selection based off of the previously placed panel and the panel above or below it is an option.

Get all panel types,
Remove the panel type which was placed to the left
Remove the panel type which was placed below
Randomly select one of the remaining panels. Move to the next cell and repeat.

Could be a fun one…

1 Like

Now I’ve uploadet the revit file in “drev” :slight_smile:

Can you elaborate on that? :slight_smile:

Likely not today - to say it’s gonna be a long day would be an understatement. Perhaps tomorrow.

This sounded fun so I tried it out. I kind of “brute forced” some things just to get it working so the code could probably be cleaned up and simplified but I think it does what you’re looking for.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('DSCoreNodes')
from DSCore import *

dataEnteringNode = IN
panels = IN[0]
colors = IN[1]

panelColors = []
rowBelow = panels[0]

for row in panels:
	rowColors = []
	rowInt = []
	panelLeft = []
	p=0
	for panel in row:
		panelBelow = rowBelow[p]
		adjacent = [panelLeft,panelBelow]
		ints = [x for x in range(0,len(colors)) if x not in adjacent]
		rInt = int(Math.Round(Math.Random(-0.5,len(ints)-0.5)))
		i = ints[rInt]
		rowInt.append(i)
		rowColors.append(colors[i])
		panelLeft = i
		p=p+1
	panelColors.append(rowColors)
	rowBelow = rowInt

OUT = panelColors
6 Likes

That’s pretty much line for line how I would have done it. Good job @Nick_Boyts!

thanks!! :smiley:

We tried to upgrade the model with your help but we cannot figure out where the problem is. Should i change anything in the python script or just copy-paste it? :slight_smile:
i’ve uploadet the dyn file in google drive.

This should work, though you should start out having the same amount of each “color” as I had to break up your lists to get it to work :slight_smile: This also means that some colors are in the wrong “place” as they are handled as a group of another color.

Ah. I apologize. I didn’t know this was specifically a learning exercise. I usually don’t like to post full solutions anyway, but this felt like something fun to try out. I was expecting multiple solutions from the forum with the hopes of a discussion around the logic. My mistake.

1 Like

As a continued learning exercise, rewriting that code in design script would be interesting as we could ‘race’ the two… it’s a great way to learn the concepts and logic as well. :slight_smile:

I was actually doing this when I was coming up with a solution… but I find Python just way easier when it comes to looping, so I gave up on the DS solution half way through. :grin:

2 Likes

Hi @Nick_Boyts and @jacob.small

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