   blender py script export
#!BPY"""Name: 'Wikibooks'Blender: 237Group: 'Export'Tooltip: 'Wikibooks sample exporter'"""import Blenderdef write_obj(filepath):   out = file(filepath, 'w')   object = Blender.Object.GetSelected()[0]   mesh = object.getData() for vert in mesh.verts: out.write( 'v %f %f %f\n' % (vert.co.x, vert.co.y, vert.co.z) ) for face in mesh.faces: out.write('f')  for vert in face.v:    out.write( ' %i' % (vert.index + 1) ) out.write('\n')   out.close()Blender.Window.FileSelector(write_obj, "Export")based on this from a blender tutorial does anyone know how i can modify to also export texture corrdinates   
Quote:Original post by Kaze *** Source Snippet Removed ***based on this from a blender tutorial does anyone know how i can modify to also export texture corrdinatesThis should do the trick:// *** src removed ***def write_obj(filepath):   out = file(filepath, 'w')   object = Blender.Object.GetSelected()[0]   mesh = object.getData() for vert in mesh.verts: out.write( 'v %f %f %f\n' % (vert.co.x, vert.co.y, vert.co.z) )   for face in mesh.faces: for i in range(0, 3):  out.write( 'vt %f %f' % (face.uv[0], face.uv[1]) )    for face in mesh.faces: out.write('f')  for vert in face.v:    out.write( ' %i' % (vert.index + 1) ) out.write('\n')// *** src removed ***;  at out.write( 'vt %f %f' % (face.uv[0], face.uv[1]) )i getTraceback (most recent call last):  File "<string>", line 22, in write_objIndexError: list index out of rangewhat to the cords 0-3 represent;Quote:Original post by Kazeat out.write( 'vt %f %f' % (face.uv[0], face.uv[1]) )i getTraceback (most recent call last):  File "<string>", line 22, in write_objIndexError: list index out of rangewhat to the cords 0-3 representThey represent the coords for each vertex of the face.Maybe the mesh is not UV mapped?   ;  probably, i just assumed it came with a default set   