# How to average the normals of mesh to corner angles using Bmesh

I am trying to do the same as

bpy.ops.mesh.average_normals(average_type='CORNER_ANGLE')

but using Bmesh instead, since Bmesh doesn't have a command for this i thought i would have to edit each vert or face normal manually. But when i edit the normal vectors of the Bmesh and then apply it to the target mesh, nothing happens, the changes aren't applied.

Here is a basic test script i am using:

odata = bpy.data.objects['Cube'].data
bm = bmesh.new()
bm.from_mesh(odata)

for v in bm.verts:
v.normal = (0.0, 0.0, 0.0)
#bm.verts.ensure_lookup_table() #These don't work either
#bm.verts[v.index].normal = (0, 0, 0)

bm.normal_update()
bm.to_mesh(odata)
odata.update()
bm.clear()


Which nothing happens when run.

Though i am able to flip the face normals successfully using:

for f in bm.faces:
f.normal_flip()

• There is only one vector that cannot be normalized, the zero vector. Have you tried with a non zero length 1 vector? – batFINGER Nov 30 '19 at 2:08
• @batFINGER Sorry I'm not sure what you mean. I am able to change the vert normal vector values of the Bmesh with no problem. But when the Bmesh is applied to the target mesh, the changes to the vert normals aren't applied. – Thiedent Nov 30 '19 at 2:20