Create UV layers from an array

I have the information of UV of one object in an array. I want to recreate the UV in a new object, so I tried to create first the uv_texture and then add the data.

The new object is equal to the object from I exported the UV data.

How can I do that?


Data[0]=<Vector (0.7360, 0.9999)>
Data[1]=<Vector (0.2920, 0.9999)>
Data[2]=<Vector (0.2920, 0.5559)>
Data[3]=<Vector (0.7360, 0.5559)>
Data[4]=<Vector (0.7360, 0.5559)>
Data[5]=<Vector (0.2920, 0.5559)>
Data[6]=<Vector (0.2920, 0.0001)>
Data[7]=<Vector (0.7360, 0.0001)>
Data[8]=<Vector (0.2920, 0.0001)>
Data[9]=<Vector (0.2920, 0.5559)>
Data[10]=<Vector (0.0001, 0.5559)>
Data[11]=<Vector (0.0001, 0.0001)>

obdata =
myUV ="UVMap")
i = 0
for e in data:
  obdata.uv_layers[].data[i].uv ???  
  obdata.uv_layers[].data.add() ????
  i += 1    

What I need to put inside for loop?

Something like this:

ob = bpy.context.object
me =
uv_layer = me.uv_layers[-1]"uv", [elem for uv in uv_data for elem in uv])

foreach_set() requires a flattened sequence of floats, so [[0.2, 0.3], [0.4, 0.5]] won’t work - thus the list comprehension to unpack it.

Can I assume that UV_Layers is created automatically (in OBJECT Mode) after create the UV_Texture?

Yes, it is. It should be safe to assume that the corresponding uv layer is [-1], but you could also a lookup by name.