Need help exporting data

I need to export mesh data to a text file, Verts, faces and UV’s. Can someone point me in the right direction ? I need a simple script as I’m new to Python. I’m using Blender 2.53

Thanks

Okay I’ve worked this much out on my own. Would be so nice if the docs were complete :slight_smile:

I did a hack and slash of the RAW triangle export scripts. working nicely so far.

Code:

def vertsToLine(verts):
line = "vertex "
v = verts.co
line += str(v[0]) + " " + str(v[1]) + " " + str(v[2]) + " "
return line[:-1] + "
"

def normsToLine(verts):
line = "normal "
v = verts.normal
line += str(v[0]) + " " + str(v[1]) + " " + str(v[2]) + " "
return line[:-1] + "
"

def export_vxo(filepath, applyMods, triangulate):
for obj in bpy.context.selected_objects:
if obj.type == ‘MESH’:
matrix = obj.matrix_world

        if (applyMods):
            me = obj.create_mesh(bpy.context.scene, True, "PREVIEW")
        else:
            me = obj.data

# write the fvirts
file = open(filepath, "w")
file.write("# vortX GE object file v0.1

“)
file.write(”# Vertex data
“)
for verts in me.vertices:
file.write(vertsToLine(verts))
file.write(”

Normal data

")
for verts in me.vertices:
file.write(normsToLine(verts))
file.close()

My output file looks like this :

vortX GE object file v0.1

Vertex data

vertex 1.0 0.999999940395 -1.0
vertex 1.0 -1.0 -1.0
vertex -1.00000011921 -0.999999821186 -1.0
vertex -0.999999642372 1.00000035763 -1.0
vertex 1.00000047684 0.999999463558 1.0
vertex 0.999999344349 -1.00000059605 1.0
vertex -1.00000035763 -0.999999642372 1.0
vertex -0.999999940395 1.0 1.0

Normal data

normal 0.577349185944 0.577349185944 -0.577349185944
normal 0.577349185944 -0.577349185944 -0.577349185944
normal -0.577349185944 -0.577349185944 -0.577349185944
normal -0.577349185944 0.577349185944 -0.577349185944
normal 0.577349185944 0.577349185944 0.577349185944
normal 0.577349185944 -0.577349185944 0.577349185944
normal -0.577349185944 -0.577349185944 0.577349185944
normal -0.577349185944 0.577349185944 0.577349185944

Okay, I’d still love some help guys. I need to export faces next, but I want to do this by material ! is this possible ???

Thanks.