you can’t actually edit normals this way- blender uses split normals for this purpose. split normals are basically an ‘extra’ set of custom normals and they are stored per loop. luckily, this is a common enough operation that there is a shortcut to set split normal data per-vert instead of per-loop:
import bpy
obj = bpy.context.object
obj.data.use_auto_smooth = True
obj.data.normals_split_custom_set_from_vertices( [(1, 0, 0) for v in obj.data.vertices] )
note that the object must be set to use auto-smooth for you to actually see the split normals.
Both functions accept an array of normals? So are you essentially passing it a full list of the new normals in the same order as the vertices? So if I really want to just change the selected vertices, I’ll generate my own list and pass that, something like this:
newNormals =[]
for v in me.vertices:
if v.select:
newNormals.append(Vector((1,0,0)))
else:
newNormals.append(v.normal)
me.normals_split_custom_set_from_vertices( newNormals )
So what does normals_split_custom_set() use instead of vertices? It still just takes a list of normals as a parameter, but the order should match something else?
normals_split_custom_set() works on loops- which is where the actual split normals data is stored. normals_split_custom_set_from_vertices() is really just a shortcut that allows people to set custom vert normals. in a closed mesh with no open boundaries, you should have four times the number of loops as you have verts- this is actually what lets you create “split” normals. if it weren’t for this, you’d actually have to detach faces/edges to make hard edges (this is actually how Blender worked many years ago).
the loop normals collection don’t contain any information until you run calc_normals, then the internal split normal data is transfered to the collection for scripting purposes.