Exporting UV-coordinates

I run into a problem … I’m accessing the uv coordinates with my python script in Blender, but they don’t seem to change from 0.0. I already textured mapped the object … set uv coords for all faces. I can view that object with the texture map on it … so why dont the uv coords change then … I’m going crazy with this :frowning:

Here is my script based on the 2.25API


objects = Blender.Object.GetSelected()
object = objects[0] # this better be a mesh :)
data = object.data
faces = data.faces

string = "Mesh Data
{"

faceNumber = 0
for face in faces:
   faceNumber+=1
   string += "
  Face" + str(faceNumber) + "
  {"

   vertexNumber = 0
   for vertex in face:
      vertexNumber += 1
      string += "
    Vertex" + str(vertexNumber) + "
    {"
      string += "
      coordinates("
      string +=       str(vertex.co[0])
      string += ", " + str(vertex.co[1])
      string += ", " + str(vertex.co[2])
      string += ")"
      string += "
      normal coordinates("
      string +=       str(vertex.no[0])
      string += ", " + str(vertex.no[1])
      string += ", " + str(vertex.no[2])
      string += ")"
      string += "
      texture coordinates("
      string +=       str(vertex.uvco[0])
      string += ", " + str(vertex.uvco[1])
      string += ")"
      string += "
    } // end of Vertex"

   string += "
  } // end of face"
string += "
} // end of Mesh"
print
print string

Was anyone ever sucessfull in exporting uv coordinates from Blender?
Someone plz help.

It probably is very confusing but ‘uvco’ are the ‘sticky’ coordinates (camera projection coordinates when using ‘Make Sticky’ in edit buttons), not the texture uv-coordinates. You need uv from the faces themselves:


for uv in face.uv:
      string += "
      texture coordinates(" 
      string +=   str(uv[0])
      string += ", " + str(uv[1]) 

Thank you! Thank you! Thank you eeshlo!

I’ve almoust gave up on Blender, but now … I can see the light … err … uv coordinates :slight_smile: