Order of vertices added using Python script and bmesh I am using Blender 2.71 and Python 3.4.0 and I would like to add a row of vertices in such a way that I can call them using bmesh.verts[] in the same order that I placed them (or in reverse).

I have placed them using the for loop:

for x in range (0,5):
    bmesh.verts.new((x,0,0))


This results in five vertices in a row starting from the origin. However, the call order for bm.verts[] is totally muddled. For example, if I then run the following:

bmesh.verts.remove(bm.verts[0])


the one that disappears is the second from the right. I would expect it to be either the left or right-most vertex. Can anyone explain to me which method Blender uses to store these vertices?

The object contains no other vertices.

I have noticed that when adding four or less the order is sequential from right to left, but something changes at five. Is this something to do with polygons?

Thanks
Short answer is no, however...

BMesh only ensure vertices are added in-order when they are added to a newly created (or converted) mesh (which is OK for importers and geometry generators).
Once vertices are removed you cant rely on this.

Best use a list of your own to keep a reference to vertices added if you need this.

Sorting

if your really need to ensure some order, you can sort verts using the same method used with Python lists eg:

bm.verts.sort(key=lambda v: v.co.x)


However it would be inefficient to sort vertices every time you add once.