Reconstructing vertices and uv separate from polygons I am trying to export the vertices, triangles, vertex normals, and UVs with blender's Python (bpy). I need code that actually works.
My program is supposed to run like this:
Loop through and create a face with UVs and verteices for each index,
Loop through vertices and create a new list of vertices and uvs that are not duplicates
Loop through faces and adjust the indices for the newer vertex list
Export
A duplicate vertex is a vertex that shares the same location and uv location as the other (I need some duplicate vertices because they do not share the same uv)
So basicly, I want to remove vertecies that have the same location and uv and create a list of faces that can go with it.
I am not sure what is wrong with my code. I could share images onces I figure out how.

#import bpy
import bpy

#my house
house = bpy.context.object.data
uv_layer = house.uv_layers.active.data

#basics
triangles = []
vertices = []
uv = []

#(the house is already split into triangles)
for i0, tri in enumerate(house.polygons):
    triangles.append([])#create a list
    for loop_index in range(tri.loop_start, tri.loop_start+tri.loop_total):
        i1 = house.loops[loop_index].vertex_index#vertex index

        triangles[i0].append(i1)#add vertex index to triangle (all I want)
        vertices.append(house.vertices[i1])#add vertex
        uv.append(uv_layer[loop_index].uv)#add uv
#new arrays
newvertices = []
newuv = []

skip = []#contain indices that should be skipped

#-1 means it should not be skipped
for i in range(len(vertices)):
    skip.append(-1)

#loop through vertices
for i, vert0 in enumerate(vertices):
    if skip[i] == -1:
        index = len(newvertices)#amount of new vertices

        skip[i] = index#this index routs to the newest vertex
        
        #create new vertex and uv
        uv0 = uv[i]
        newvertices.append(vert0)
        newuv.append(uv0)
        
        #loop through remaning vertices
        for j in range(i+1, len(vertices)):

            #create vertex2 and uv2 for testing
            vert1 = vertices[j]
            uv1 = uv[j]

            #if vertex1 is vertex2
            if vert0.co == vert1.co:
                #if both vertices have the same uv
                if uv0 == uv1:
                    #mark this index as skippable and rout it to the newest vertex
                    skip[j] = index

newtriangles = []
#re-order triangles
for i in range(len(triangles)):
    newtriangles.append([])
    for j in range(len(triangles[i])):
        newtriangles[i].append(skip[triangles[i][j]])
        
vertex_str = &quot;&quot;
normal_str = &quot;&quot;
triangle_str = &quot;&quot;
uv_str = &quot;&quot;

for vertex in newvertices:
    vertex_str += &quot;%s,%s,%s,&quot;%vertex.co[:]
    normal_str += &quot;%s,%s,%s,&quot;%vertex.normal[:]
for tri in newtriangles:
    triangle_str += &quot;%d,&quot;%tri[0]
    triangle_str += &quot;%d,&quot;%tri[1]
    triangle_str += &quot;%d,&quot;%tri[2]
for uv in newuv:
    uv_str += &quot;%s,%s,&quot;%uv[:]

f = open(&quot;c:/users/.../desktop/house/triangles.txt&quot;, &quot;w&quot;)
f.write(triangle_str)
f.close()
f = open(&quot;c:/users/.../desktop/house/vertices.txt&quot;, &quot;w&quot;)
f.write(vertex_str)
f.close()
f = open(&quot;c:/users/.../desktop/house/normals.txt&quot;, &quot;w&quot;)
f.write(normal_str)
f.close()
f = open(&quot;c:/users/.../desktop/house/uv.txt&quot;, &quot;w&quot;)
f.write(uv_str)

[2]: https://i.stack.imgur.com/xAGM0.png![enter image description here](https://i.stack.imgur.com/ihNKb.png)
I was putting skip into triangle when skip was already the triangle face re-ranged