I'm iterating through the loops of my mesh and would like to get the face it is attached to (so I can get the face's normal). I'm looking specifically for the face normal, not the vertex or loop normals. The docs provide information for finding the associated vertex, but I can't find anything to get the face index. Is there a way to do this?

    for obj in ctx.selected_objects:
        if obj.type == 'MESH':
            mesh = obj.data
            for l in mesh.loops:
                v = mesh.vertices[l.vertex_index]
                #looking for face here

Loop the faces

Suggest this is easier to loop the faces and get the loop indices.

for f in mesh.polygons:
    print(f.index, f.loop_indices)

default cube

0 range(0, 4)
1 range(4, 8)
2 range(8, 12)
3 range(12, 16)
4 range(16, 20)
5 range(20, 24)

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.