Setting UV's of a mesh with an array of vertex coordinates I've been trying to set the UV's of a mesh i created via code, and i have an array of vectros with the U and V coordinates, the problem is, the way to set up the UV's via the API seems to be via MeshLoops, which confuses me because, in this case, my mesh has 128 vertices, and on the UV Layer there's 384 Mesh UV Loops, which from what i understand, consist of one edge and 2 vertices in it.
This confuses me because this means there are repeated vertices in it, regardless of wether those verts are broken or not, and i do not know how to assign the texture coordinates to the proper vertices.
here's my code: (obj is the object that contains the mesh in it, and msh is the mesh itself)
            msh.from_pydata(data[i].vertices, edges, data[i].faces)
            uv_layer = msh.uv_layers.new()
            print(obj.data.uv_layers.active.data[0])
            #for j in range(len(obj.data.uv_layers.active.data)):
            for j in range(len(data[i].uvs)-1):
                obj.data.uv_layers.active.data[j].uv = (data[i].uvs[j][0], 1-data[i].uvs[j][1])

This obviously doesn't work, because i'm not assigning data[i].uvs array to the proper uvs on the uv_layer. How could i approach properly adding the texture coordinates to my mesh with my array? I'm not sure how to apply this with this API, and the meshloop doesn't seem to favor the way i stored my coordinates.
Thanks for reading!
Does the order of UVs in your array match the order of vertices in the mesh? If so, for every loop you assign it's uv based on the its vertex index.
ob.data.uv_layers.active.data[loop.index].uv =( data[loop.vertex_index][0],  data[loop.vertex_index][1])
To clarify, as far as I remember, each face has a loop per vertex - this allows you to have multiple normals/uvs per vertex. In your case you only need a single uv per vertex, which can be achieved by setting the same uv value to each loop that corresponds to the same vertex.
Answer based on Get/Set coordinates for UV vertices using Python