5
$\begingroup$

I am in edit mode and using bmesh to get all faces. I am iteration through the faces and their vertices. Now I want to know on how many faces the vertex, I currently have, is part of.

For example this green vertex is part of many faces.

enter image description here

Right now I have:

for f in mesh.faces:
    for v in f.verts:
        # some stuff before
        # now I need the number of faces the vertex c is part of
        # some other stuff

I know I could simply run through all faces and save the coordinates of the vertices and compare them with other faces and their coordinates - but maybe this can be done more easily.

Thanks!

$\endgroup$
  • $\begingroup$ related: blender.stackexchange.com/questions/28934/… $\endgroup$ – zeffii May 17 '15 at 13:18
  • $\begingroup$ Uh, you are right, the link_faces were there, too! I knew this was similar but haven't found it while skipping over it. Sorry! I still am learning. $\endgroup$ – Hamburml May 17 '15 at 13:45
  • $\begingroup$ it's OK, it might better to have some overlap in questions, because there are many ways to ask a question, even if the answer is similar to all. Search results become better by directing to fewer related results. $\endgroup$ – zeffii May 17 '15 at 13:57
5
$\begingroup$

a very nice feature of bmesh :)

import bpy
import bmesh

me = bpy.context.object.data


# Get a BMesh representation
bm = bmesh.new()   # create an empty BMesh
bm.from_mesh(me)   # fill it in from a Mesh

for f in bm.faces:
    for v in f.verts:
        lf = v.link_faces
        print('num faces:', len(lf), 'faces: ', lf[:])
    break 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.