Polyline from grid of point

Hello Guys,

Does anyone know how i can connect each corner of the squares with polyline that create a cross (like the draw exemple)? My goal is to make those polyline follow the position of some corner if they are updated.

Pattern_Research_Template.gh (9.7 KB)

Thanks

Key to the solution is a proper data-structure.

  • index every square by its (i,j) variable
    – i is from left to right
    – j is from top to bottom

  • order the points of the squares
    – 0 is left bottom
    – 1 is right bottom
    – 2 is right top
    – 3 is left top

  • get the neighbors
    – the square (i,j) has 4 potential neighbors
    — (i-1,j-1) is the left bottom
    — (i+1,j-1) is the right bottom
    — (i+1,j+1) is the right top
    — (i-1,j+1) is the left top

  • grab the vertices and connect them
    – v0 of (i,j) with v2 of (i-1,j-1)
    – v1 of (i,j) with v3 of (i+1,j-1)
    – v2 of (i,j) with v0 of (i+1,j+1)
    – v3 of (i,j) with v1 of (i-1,j+1)

(check the indices, there may be some errors, but in principle this would be the way)

the result of your definition is a single list of rectangles, which are sort by columns:

branching them in Lists sorted by columns would help very much, and you can get how many rectangles you have for each column from here in your definition:

which results into something like this:

now it’s much easier to identify things, because:

stuff is described as { Column } (element starting from bottom)

and for each rectangle you want to describe these two lines A and B:

Line A you can think about “from current rectangle take corner 3, and connect with rectangle one column to the right and one rectangle up, at corner 1”

Line B you can think about “from current rectangle take corner 2, and connect with rectangle one column to the right and one rectangle down, at corner 0”

those {+1}(+1) and {+1}(-1) are exactly the Offsets we give to Relative item, then with Deconstruct Brep we pick the right vertex of each rectangle

Final result:


Pattern_Research_Template_inno.gh (23.6 KB)

well… they are squares by the way :slight_smile: not rectangles lol

3 Likes

ahah thanks a lot for your time! :wink:
Looks like i was on the right way on another test but didn’t go this far

Still a beginner in grasshopper so some data-structure are still blurry to me but thanks for this !

missing

And the code is so complex! What a pity. So I simplified it…
I was surprised at first that this appeared to do it:



Pattern_Research_2024Mar27a.gh (11.1 KB)

Until I realized that it has duplicate points and the lines are not in pairs. So I added the white group:



Pattern_Research_2024Mar27b.gh (24.0 KB)

1 Like

Looks a bit easy to handle. Thanks Joseph i’ll try to play with this different approach

don’t worry, everyone has to start somewhere. Always try to seperate the geometry and the logic behind it.