I'd like to use a python script to transfer normals to a new uv layer. Here is my first attempt:
import bpy
ob = bpy.context.object
for loop in ob.data.loops:
normal = ob.data.vertices[loop.vertex_index].normal
ob.data.uv_layers["XY"].data[loop.index].uv = (normal.x, normal.y)
ob.data.uv_layers["ZW"].data[loop.index].uv = (normal.z, 0)
What I eventually want the script to be able to do is read custom split normals. I heard this was possible through the use of this script. The normal section underneath is supposed to calculate the normals using calc_normals_split or calc_tangents. However every time I try to incorporate this into my script I keep getting error messages or the result comes out as just one color. If anyone could help me to make it work would be much appreciated.

ob.data.calc_normals_split()you access the normals withloop.normal. What error message are you getting? Make sure you are in object mode and not edit mode when you run the script. – scurest Oct 13 '21 at 23:34