Help with a Grasshopper Lattice generator definition

I’ve made a couple of attempts at working out a definition in grasshopper and am at the point where I need help. I’ve built a lattice generator in Cinema 4D using Espresso and am trying to recreate it in Grasshopper. I’ll include the flow chart from Espresso and a screenshot of the Cinema 4d version. The two programs are different enough that I’m at a loss as how best to approach the problem in GH. I’ll also include my two incomplete attempts in GH. The end goal is a definition that allows to use sliders to increment the number of ‘slats’ in both X and Y planes. The slats are planar surfaces but could be rectangles or boxes. I use these finally as 2D drawings so surfaces is fine. I would like to be able to draw a frame outline and populate it with slats that maintain the overall dimensions of the frame. That part is pretty easy. Where I get stuck is how to create the maths/formulae in GH that keep the slats centered and bound to the frame, as well as not drawing slats at the perimeter of the frame. This means that the combined width of the total number of slats is subtracted from the frame height or width and the results are evenly spaced with no slats at the start and end of the frame opening, all spaced equally within it, like a shoji screen would look. In Cinema 4D I used what are essentially User Objects and I’ve found a plugin to do that in GH but am struggling with that as well. I’m new to Rhino/GH and this is my first project, so you know.

I’ve attached my two versions but I think V2 is the only viable one thus far as it uses a Series rather than an array and seems to offer more control over creating the required logic.

Any advice is welcome on how to implement this in GH. I’ve watched an entire collection of In tutorials on GH and I did not learn what I need to make this happen, so your assistance/advice is greatly appreciated.

Rhino lattice (10.2 KB) Rhino lattice generator (15.2 KB)

There are probably many other ways…

Rhino lattice (27.0 KB)

Well, I was hoping for some direction and you’ve gone and solved the whole problem, with two different styles! I’m blown away, thank you so much. Now to the task of dissecting what you’ve done so I can learn what I need to know.
I hope that others find this GH definition and find it as useful as I do.

Some additional keywords to help others find it, shoji, muntin, mullion, trellis, grate.

Again, this is profoundly helpful, thank you.