0
$\begingroup$

I'm trying to get the split normal direction value of a selected vertex using python, but I'm not being able to do it. All help is apreciated

$\endgroup$
2

1 Answer 1

1
$\begingroup$

Vertices do not have split normals. Each corner of a face has a split normal. That's what "split" means, it's how there can be different normals on either side of a sharp edge. For example, look at a flat-shaded cube. There are three split normals at each single vertex, one for each face.

Flat shaded cube showing three split normals per corner

Blender internally calls a corner of a face a loop. To get the split normal for a loop, you do this

# This calculates all split normals, you must do this once
# before you can access them or they'll all be (0,0,0)
mesh.calc_normals_split()

# Get split normal for i-th loop
mesh.loops[i].normal

This works for a Mesh (object mode). Accessing split normals for a bmesh (Edit mode) is unsupported (ref).

If want you want is a list of all split normals at all selected vertices, you would have to iterate through all the loops

mesh.calc_normals_split()

split_normals = [
    loop.normal
    for loop in mesh.loops
    if mesh.vertices[loop.vertex_index].selected
]
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .