Blender 2.6: Exporting UV Texture Coordinates
There is nothing I admire more then a software development team that is not shy of reorganizing an API to the better even though it means stepping on some peoples feet. Well, I guess the Blender team stepped on my foot; because one of my export scripts was no longer working once I upgraded to Blender 2.6. Actually, I should have known; because it is more the rule then the exception that the Python API changes from release to release…
This time it took me some hours to find how to get to the UV texture coordinates of a mesh. After browsing through the API via the python console for some time I took the easy way out and peaked into the .OBJ model exporter coming with blender. So, here is how you get to the UV textures of a triangle for your mesh:
m = bpy.context.active_object.to_mesh(bpy.context.scene, True, 'PREVIEW') uv1 = m.tessface_uv_textures.active.data.uv1 uv2 = m.tessface_uv_textures.active.data.uv2 uv3 = m.tessface_uv_textures.active.data.uv3
The part of the data path that has changed (at least I was able to get to the UV coordindates differently in the past) is the tessface_uv_textures property.
Note that i am accessing index  here. The array indices correspond to the indices of the faces-array. So, this example is for face zero. Also note that the uv1 to uvx depend on how many vertices the face has. Often you would first triangulate the mesh to have only primitive polygons.
I hope t helps someone because also google mostly shows up with results for accessing the UV coordinates that are deprecated for some time by now and thus are no longer working.