Re-Structuring Order of Grid Items into Smaller Grids

I am attempting to create a grid system that I will later use for pixel data for a mosaic project, but am struggling with a crucial layout step involving the organization of the sub-grids that I’ll need.

In my picture, I have a basic index numbering system on the left of the square grid component I’m using, and I’ve shown the numbering order I’m starting with, and how I am hoping to have it grouped on the right.

Is there a simple way to do this that I can take advantage of?


grid_example.gh (7.6 KB)

One way could be:

def num_block():
    j = 0
    s = ""
    for i in range(0,81):
            s += f"{i%3+j:>3}"
            if (i+1)%9==0 and i > 1:
                    s += "\n"
                    j = j+3 if j < 6 else 0
    return s

print(num_block())
3 Likes


Nick.gh (5.8 KB)

4 Likes

I had to download this out of complete amazement!
That’s tree manipulation on another level!
But… This topic is also making me want to learn to code again because that looks a lot simpler!

This exercise did not disappoint, very fun stuff


GridSubdivision.gh (13.7 KB)

3 Likes

Can I challenge @Artstep and @Mahdiyar to look at this please?..
https://discourse.mcneel.com/t/construct-mesh-from-rectangle-vertices/190650
It’s a similar data structure challenge where I’m trying to get a list of rectangle vertices into lists of 4 vertices to make quad mesh faces. Solved in the thread using script but I always wonder if it’s possible to do it with just native GH components.

1 Like