Move a series of elements randomly until it reaches a total constrained area

Hi everyone,

I’m trying to move/copy elements upwards until they reach a total given area. As they are building volumes I would like to have random numbers of floors for each building with even distance between floors. So far I have try this but now I’m stucked on how I should continue.
Can anyone guide me in the right direction?

This is the script :arrow_down:

This is how it should look :arrow_down: (depending of course of the total area/ramdom seed) (11.6 KB)

for each of the buildings create a random number, for instance between 1 and 10 (for the number of floors), then use that number to create a series for the height offset of the floors, and use these vectors to move the starting floor in the positive Z direction. You can easily calculate the sum of the areas of these surfaces once this is done and use that to evaluate.

Thanks for the answer Devin. If I understand your answer you are adjusting the number of floors to try to match the area needed but What I need is to change the total square meters and generate different number of floors configurations respecting this given area.

Ok, in this case, you will need to take the total area as input, then divide it by the area of one floor to determine how many floors you need. Then you could also have as input the length or width of one floor, then use the total area and a random number of floors and then you can make the number of floors randomized. Here’s what that would look like:

Building (9.9 KB)

Yes, but that will work with just one building and not 5 or 6 as I would like :thinking:

This can be pretty easily achieved using the script I posted as a starting point. Let me know how it goes for you

1 Like

Thanks a lot Devin. I tried and could not find a solution to this problem. Thanks a lot anyway :slight_smile:

Once you know, it’s not so bad. You will learn :wink:

MULTI-Building (10.4 KB)

1 Like

Thanks a lot Devin! This solution gives the written total area by building (in your example 11292 per building, so a total of 101628 counting the 9 buildings). I will continue to modify it to find a total (11292) for all of the buildings :slight_smile: