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
Asked
Active
Viewed 761 times
0
-
Calculating split normals using python? ... How to set custom vertex normals for certain vertices using python? ... There is a way to add custom split normal use Python API? – pyCod3R Jan 09 '22 at 19:56
-
Sorry but none of those links answers what I asked. Just need to get the Vector3 direction of a single selected vertex's split normal. I'm not looking to set or change anything of the mesh. – JuanSalice Jan 10 '22 at 13:37
1 Answers
1
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.
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
]
scurest
- 10,349
- 13
- 31
