Evenly sized panel script

I was asked to write a Grasshopper script for evenly sized panels. Each panel is 10.5’ x 3.75’. It feels like a pretty straightforward ask. However, I am running into an issue with the leftover space.

The space leftover is required to contain panels no less than 9.0’ located in the center of the area. Maybe I am overthinking this, but I cannot figure out how to accomplish that part. I have attached a screenshot for reference. You can ignore the green panels because those will always be 7.875’.

For reference, the overall length would be the primary variable being adjusted. Let me know if I need to clarify any of the information. Any insight would be greatly appreciated.

Capture

looks like this is your base scenario:

where you need to populate length A with panels of length 10.5 until the unpaneled area measures at least 9 units

from your image looks like the number of panels length 10.5 must be even: is it a requirement? or just happened to be like that in your example?


this calculates the best combination keeping total length fixed, maximizing the number of standard panels:

let’s say main panels (10.5 length) do not have to be an even number, I would do something like this:

the 3 text containers on the right are the reference data of interest, as they wiil give you the possible combinations to divide your length

we want the leftover panels to measure at least 9 units but no more than 10.5, so we can keep all the solutions for which that value is >=9 and <10.5 :

all these solutions would be good, but we want to maximize the number of standard panels, so we take the last row of values:

just as verification:

of course, if you are in a situation with total length like the one in your image, where you can fill the total length of 128 units by just using main panels, you need to stop earlier and take that solution from the beginning, and ignore the rest of the calculations:

this part in red should take care of that:

weird_panels.gh (25.6 KB)

Thank you so much! I believe it does have to be even, but this at least gets me on the right path. Your explanation is extremely helpful. The big err I made was trying to visualize it first. Since this does need such specific values, you are right that I should have started by calculating them.

To achieve that, I am thinking I should create a slider restricted to even values. Then I can multiply that value by 10.5 and take it away from the overall length.

L-(10.5N)=x

X would give me the leftover amount, and I could divide that by the number of middle panels and it could tell me the leftover panel size. This way feels a lot less elegant than your script because it has more parameters, but it’s the simplest way I can think of. Let me know if you have any other ideas.

I’ll reply here if I get stuck again. I’m going to work on what I wrote above and something that will lay them all out.

Okay, it’s a little clunky, but it’s passable. I’m curious if you have any thoughts on how this could be optimized. It does require a human to check if the middle panel values are beyond the extremes (9 and 10.5). I took more of a brute force approach to getting the main panels to be an even amount.
weirder_panels.gh (23.8 KB)

a maybe easier fix to get only solutions where the number of standard panels is always even, might be to generate a serie of only even numbers:

the Value List + Filter let you do that pretty fast

working with sliders is fine, we are both bruteforcing it, but while a slider lets you see only that particular solution for that value, a Serie of numbers can show you multiple solutions simultaneously… so I prefer series :slight_smile:

this last part here takes care of the 3D

weird_panels_Re.gh (18.6 KB)

[I also reworked a faulty logic from my previous post…]