Strategy to turn a grid of lines into a grid of cells?

Hi folks,

I have a collection of intersecting lines that visually represent a grid, and I’m looking for a strategy to get grid cells (closed polylines) from them.

I’ve already sorted the lines into vertical and horizontal ones, in consecutive order.
The strategy will be part of a bigger Python script, however I’m open to any suggestion (even vanilla Grasshopper ones).
It would also be great, if this would be feasible without recurring to expansive surface divisions (if at all possible). (15.4 KB)

Thanks. :slight_smile:

Dave Stasiuk provided a nice vb script for line network in this rescent topic.

Canvas%20at%2023%3B30%3B54 (16.3 KB)


Pufferfish has a nice tool for it.


I don’t understand what you mean by strategy ; if you mean sorting cells in x or y direction you can do that by sorting points
And finding cells from lines you can use split surface or Heteroptera region

1 Like

Heteroptera Geometric Region does exactly what you want, if you’re ok with using plug-ins.

RE_linestogridcells (15.6 KB)

1 Like

@HS_Kim, thank you! The VB script works great. Now, i only need to translate it to Python. It’s gonna be a challenge though, since I don’t know much about VB. :star_struck:

@ebe, @seghierkhaled, and @jaymezd, thanks, but I explicitly asked for a strategy that doesn’t involve costly surface operations, like splitting.
Furthermore, third-party components don’t really help me in this case, since I need to be able to reproduce/reverse-engineer the whole process, in order to integrate it into a more extensive Python script.
Great recommendations though, guys! Mayhap somebody else will find this useful someday. :slight_smile:


This is another method (26.6 KB)

1 Like

Is this discussion relevant?

1 Like

2nd method , the two methods about finding the centers of polygons than the 4 closest points (40.5 KB)

1 Like

@DanielPiker, thanks for the link. I’ll check it out.
@seghierkhaled, thanks for all the time you spend on this. Which plugin has the curve middle component?

I don’t think it is a plugin, it appeared in the curve analysis weeks ago, if you don’t have it use point on curve

1 Like

Where does it go? Could you post a screenshot please?


LOL, no, I mean in the definition, since it’s missing somewhere!

Ok i don’t understand you (43.0 KB)

1 Like


1 Like