Hi there,

I am new and struggling a bit with GH

My question is, in a mesh of quads

Is there a way to select the faces that are connected to a selected vertex?

That would be extremely useful

Please

Help!

Hi there,

I am new and struggling a bit with GH

My question is, in a mesh of quads

Is there a way to select the faces that are connected to a selected vertex?

That would be extremely useful

Please

Help!

Welcome @bdessi1016,

Absolutely, here’s an example using a custom GHPython component:

Meshes are composed of mainly **vertices** and **faces**. The vertices are stored in a **list of three-dimensional points**, whereas each faces is a **collections of vertex indices** from the vertex list. Each quad face has for instance four indices, referring to the vertices it is composed of. The face vertices are conventionally ordered in a **counter-clockwise** manner.

This means that we only have to check which vertex index is included in a face of vertex indices to see, which faces the vertex in question is part of.

The Python script is rather simple:

```
from ghpythonlib import treehelpers
vertex_findices = [] # nested list of face indices per vertex
for i in xrange(Mesh.Vertices.Count): # loop vertices
indices = [] # face indices for the current vertex
for j in xrange(Mesh.Faces.Count): # loop faces
if i in Mesh.Faces[j]:
# the vertex index is includes in vertex indices of the current face
indices.append(j)
vertex_findices.append(indices)
# Outputs
vIndices = [i for i in xrange(Mesh.Vertices.Count)] # list of vertex indices
fIndices = treehelpers.list_to_tree(vertex_findices) # tree of face indices for each vertex
```

Please note that if you’re using a Rhino version, older than 6, you need to install GHPython, if you haven’t already.

adjacent_faces.gh (8.8 KB)

I DON’T KNOW HOW TO THANK TO YOU

I took my time to answer because i needed a rest of this after being several days trying

<3

best regards!