Picking Adjacent cells using Grasshopper

Hi,
Is there a Grasshopper solution to pick all adjacent cells of one selected cell in an array?


Thanks

How is your array structured? A single list winding its way through all columns? A collection of cells in adjacent columns? Random?

Yes, it’s a single list.

If they are more like squeres, I could have simple sulotion. If they are rectangles, the way I have so far is using list to select.

You can do it testing intersections, will work for arbitrary grids as well as long as cells touch.


Gif
HiNeighbor.gh (8.6 KB)

Vor

4 Likes

2 Likes

thx, this is really simple.I have never use the test intersection command

1 Like

If you have a large amount of cells a mesh would be way faster

1 Like

near.gh (13.6 KB)

Well yes because you are using sandbox topology plugin :smiley:

is this like cheating? :grinning:
I had a brief look in the rhino common but it gave me wrong indices:

Edit: I also tried the Brep topology component without success.

Nope it is not cheating :smiley: , just mentioning it before they download it and you get the “I don’t have this plug-in” comment. But I guess it will only work for quad and tri cells being a mesh, however @Clive did just show rectangular so seems ok.

You are rigth, I forgot to put the bifocals.It also uses Mesh explode from Mesh edit I think.
If I remember right the nGon plugIn has also a topology component.

In regards to the mesh/topology approach, the rhinocommon methods work as expected, (at least in Rhino 6)
Here is a sample that exposes some rhinocommon approaches you could use. (in a GHPY component)

1 - get the indexes of adjacent faces to a specific mesh face, (sharing an edge)
2 - get the topological verticies for the specific mesh face, then find any face sharing one of those vertices
3 - explode the mesh, (create an individual mesh for each mesh face)

output adjacent faces: (sharing an edge)
AdjFaces_ShareEdge

output adjacent faces: (sharing a vertex):
AdjFaces_ShareVertex

import ghpythonlib.treehelpers as th

AF = x.Faces.AdjacentFaces(y)
tVerts = x.Faces.GetTopologicalVertices(y)
c = [x.TopologyVertices.ConnectedFaces(tpt) for tpt in tVerts]
x.Unweld(0, True)
M = x.ExplodeAtUnweldedEdges()
CF = th.list_to_tree(c)
FCF = set([i for iArray in c for i in iArray])

attached file has a few more comments.
AdjFaces_GhPy.gh (10.7 KB)

3 Likes

thanks @chanley,
I did it wrong, nice to know it is just one line, its really mighty.

And thanks for the explanation!

@Michael_Pryor
Thanks for your solution,
I expanded the code, so that it goes through all cells, picking their neighboring cells.
The only problem is, in a 16 cell frame, the “Cull Index” iterates 16*15 = 240 cells.
It literally drains the memory to process a higher number of cells.
Picking Adjacent cells.gh (17.6 KB)

Is it faster than doing in manually? :smiley:

It can be faster if your cells are quads or tri, then you can use mesh topology.

Probably not, :thinking:
As I’m dealing with 6400 cells,