Any coders around today?

Does anyone know how to get a list of edges that are a part of a face. I know how to get the list of edges for the entire mesh, but not sure how to deal with just one face at a time.

Confusion! I think I understnd now.


    for f in m.faces:
        edge_list=[]
        for key in f.edge_keys:
            edge_list.append(key)

without checking

 

edge_list=[]

for f in m.faces:
    for i in range(len(f.v)):
       ip = (i + 1) % len(f.v)
       edge_list.append(m.findedge(f.v[i], f.v[ip]))

Try this against the default cube. Perhaps there is enough here to help you along with what you want to do


import Blender
from Blender import Mesh

mesh = Mesh.Get("Cube")

for face in mesh.faces:
    print '-----------------------'
    
    edge_key_list = [ key for key in face.edge_keys ]
    print edge_key_list
    
    edges = mesh.findEdges(edge_key_list)
    
    for edge_index in edges:
        print 'edge index', edge_index, 'MEdge', mesh.edges[edge_index]

For me it prints the following:


-----------------------
[(0, 1), (1, 2), (2, 3), (0, 3)]
edge index 1 MEdge [MEdge (0 1) 0 1]
edge index 0 MEdge [MEdge (1 2) 0 0]
edge index 3 MEdge [MEdge (2 3) 0 3]
edge index 2 MEdge [MEdge (0 3) 0 2]
-----------------------
[(4, 7), (6, 7), (5, 6), (4, 5)]
edge index 7 MEdge [MEdge (4 7) 0 7]
edge index 6 MEdge [MEdge (6 7) 0 6]
edge index 5 MEdge [MEdge (5 6) 0 5]
edge index 4 MEdge [MEdge (4 5) 0 4]
-----------------------
[(0, 4), (4, 5), (1, 5), (0, 1)]
edge index 9 MEdge [MEdge (0 4) 0 9]
edge index 4 MEdge [MEdge (4 5) 0 4]
edge index 8 MEdge [MEdge (1 5) 0 8]
edge index 1 MEdge [MEdge (0 1) 0 1]
-----------------------
[(1, 5), (5, 6), (2, 6), (1, 2)]
edge index 8 MEdge [MEdge (1 5) 0 8]
edge index 5 MEdge [MEdge (5 6) 0 5]
edge index 10 MEdge [MEdge (2 6) 0 10]
edge index 0 MEdge [MEdge (1 2) 0 0]
-----------------------
[(2, 6), (6, 7), (3, 7), (2, 3)]
edge index 10 MEdge [MEdge (2 6) 0 10]
edge index 6 MEdge [MEdge (6 7) 0 6]
edge index 11 MEdge [MEdge (3 7) 0 11]
edge index 3 MEdge [MEdge (2 3) 0 3]
-----------------------
[(0, 4), (0, 3), (3, 7), (4, 7)]
edge index 9 MEdge [MEdge (0 4) 0 9]
edge index 2 MEdge [MEdge (0 3) 0 2]
edge index 11 MEdge [MEdge (3 7) 0 11]
edge index 7 MEdge [MEdge (4 7) 0 7]