Help: Exporting UV information

hello,

I’m writing a Blender python export / C++ import script combo for use in some of my OpenGL experiments.
So far i’ve exportet vertex coordinates, vertex normals, face indexes and vertex color layers.
The last thing i need right now would be uv layers and uv coordinates and that’s where i’m struggling. I can’t find this data in the blender data structures. I’m using blender 2.5 (and i’m aware that it’s API may change… but I simply prefer the new UI to the old).
Basically I’m looking for any help regarding accessing uv info with python in blender 2.5+.

Thanks in advance :slight_smile:

I had a look (the included exporters and the new interactive python console are a great help) and this is what I came up with:

obj = bpy.context.selected_objects[0] #or whatever your object is
mesh = obj.data #provided it's a mesh object - or get it however you like
uv = mesh.uv_textures[0].data #provided len(mesh.uv_textures) > 0
for face in uv: #loop through the faces
  print("next face:")
  for vertex in face.uv: #loop through the vertices of the face
    print(vertex[0], vertex[1]) #print uv coordinates
    #or do whatever you want with it

Mr. Wonko

thanks a lot, that seems to work :slight_smile:

I’ll post some progress later.