UV question, accessing data

I am in the process of making a little custom export script for my uv textured models in 2.5.4.

At the moment I can see its possible to loop through the mesh data, then faces to export the verts. Now my problems comes when I want to export the faces uv information.

Have a look at this snippet of code first…


import bpy

ob = bpy.context.selected_objects[0]    #It is a mesh object with a uv channel
uv = ob.data.uv_textures[0]             #Uv data from the 1st channel

print("type =", ob.type, " name =", ob.name)   #Show the type and name of the selected object
    
print("number of faces in mesh data: ",len(ob.data.faces))    
print("number of faces in the uv data: ",len(uv.data))    
      
print (ob.data.faces[0])    #First face in the list
print (uv.data[0])            #First face in the uv list

How do I know what face the UV data is for as they are both lists of different types.

From what I can see the len(ob.data.faces) = len(uv.data) always!. Is this true?
If the above is true, does that mean uv.data[0] is the data for ob.data.faces[0]?

After re-reading the above, I guess what i am trying to ask is that given this…

ob = bpy.context.selected_objects[0]

For the above object,

ob.data.uv_texture.data[0] = ob.data.faces[0]

is this the uv data for this face?

Hmm, I do not know, but if I subdivide a plane and select 3 of the 4 faces and make an unwrap, there are only 3 faces in the uv-editing window …WHAT does this mean?
And in a more complicate mesh???

In your little example you will find len(faces) and len(of uv data) are both 4.

This is because even if you have not unwrapped the 4th face, it still has uv data.