I want to readout the the UV-coordinates for a given object. The first thing I notice is, that in the UV-editor the coordinates are given in pixel-space while via Python they are given as percentage. Ok, I think I can deal with it.
However, the coordinates do not seem to resemble what I see in the editor. Here is an example:
I created a plane, subdivded it, unwraped it and everything is fine. Now, as an illustration of the problem, I want to depict the uv-coordinates in 3D. I do this with the following code:
import bpy
object = bpy.data.objects['Plane.001']
world_d = []
uv_d = []
for i in range(0, len(object.data.vertices)):
object.data.vertices[i].co[0] = object.data.uv_layers.active.data[i].uv[0]
object.data.vertices[i].co[1] = object.data.uv_layers.active.data[i].uv[1]
object.data.vertices[i].co[2] = 0
To my surprise, the mesh looks like this:
Has anybody an idea what went wrong or how to access the uv-coordinates that I can see in the UV-editor?