Hi, I’m making a script that optimizes meshes. It removes or merges the vertices contained in an edge, but only if the edge and all it’s vertices are aligned forming a straight line. The result would be an edge defined by only 2 points, the vertex where the edge begins and the vertex where the edge ends.

Here’s what I’ve done so far:

```
# -*- coding: utf-8 -*-
import Blender
from Blender import Object
import math
EditMode = Blender.Window.EditMode()
if EditMode: Blender.Window.EditMode(0)
me = Object.GetSelected()[0].getData()
### Print Object Coordinates and set vertlist
print me.name, 'coordinates:'
vertlist = []
for v in me.verts:
#if v.sel: #Isolar vertices isolados
print v.co[:]
vertlist.append(v.co[:])
### Round vert coordinates
for i in range(0,len(vertlist)):
for s in range(0,len(vertlist[i])):
vertlist[i][s] = float("%0.2f" % (vertlist[i][s]))
print "----------------------------------------------"
#print vertlist
print "----------------------------------------------"
def middlePoint():
global a,b,c,dict,A,B,C
dict={"a":a,"b":b,"c":c}
print A,B,C
x=[A[0],B[0],C[0]]
y=[A[1],B[1],C[1]]
z=[A[2],B[2],C[2]]
x.sort()
y.sort()
z.sort()
p=["a","b","c"]
pco=[A,B,C]
for n in range(0,3):
if x[1]==pco[n][0] and y[1]==pco[n][1] and z[1]==pco[n][2]:
MiddlePoint=p[n]
break
return dict[MiddlePoint]
######################## Find parallel edges
test_true_count=0
for a in range(0,len(vertlist)-2):
for b in range(a+1,len(vertlist)-1):
for c in range(b+1,len(vertlist)):
A = vertlist[a]
B = vertlist<b>
C = vertlist[c]
# Pertencem a uma recta?
#if (C[0]-A[0]) / (B[0]-A[0]) == (C[1]-A[1]) / (B[1]-A[1]) == (C[2]-A[2]) / (B[2]-A[2]):
# print a,b,c
AB = [B[0]-A[0],B[1]-A[1],B[2]-A[2]]
AC = [C[0]-A[0],C[1]-A[1],C[2]-A[2]]
ProEsc = (AB[0]*AC[0]+AB[1]*AC[1]+AB[2]*AC[2])
ABmod = math.sqrt(AB[0]**2 + AB[1]**2 + AB[2]**2)
ACmod = math.sqrt(AC[0]**2 + AC[1]**2 + AC[2]**2)
cosh = math.cosh(ProEsc/(ABmod*ACmod))
if cosh == 1:
#print AB,AC," "*2,a,b,c," "*2,A,B,C
test_true_count+=1
if not test_true_count:
print "No cos=0 found"
else:
print "Found",test_true_count,"parallel edges"
#me.verts[b].co[1]=20
#me.update()
if EditMode: Blender.Window.EditMode(1)
```

[B]How do I delete a vertex and how do I merge it with another vertex?

Because if i have a cube and after running the script in the system console I type me.verts.remove(1) blender says that it’s not in the list, why??

Thanks