If I base a script on vertex indices -- how much risk that the index will change with time? Is it possible to assign some identifier of my own to a vertex? For example, add a uuid for every vertex I am interested in.


1 Answer 1


In general vertex indices are not a reliable way to keep track of vertices.

However in some cases you can't avoid using them (MDD/PC2 animations and texmesh feature for example), basically - as long as you only deform the geometry and don't add/remove/subdivide... etc. They can be used - but users of your tools need to be aware of this limitation. If you can avoid relying on vertex indices, its normally best to do so.

This example shows why vertex indices aren't safe as reference:

import bpy

bpy.ops.object.mode_set(mode='EDIT', toggle=False)

ob = bpy.context.object
verts = ob.data.vertices

print("Before", verts[0].co)
# could also be edge-split, subdivide, knife-project, delete ... etc
bpy.ops.mesh.sort_elements(type='RANDOMIZE', elements={'VERT',})
print("After", verts[0].co)

# Before <Vector (1.0000, 1.0000, -1.0000)>
# After <Vector (1.0000, 1.0000, 1.0000)>

You should look into custom data layers:


  • 1
    $\begingroup$ Is there a safer identifier for a vertex? Can I make an identifier of my own? $\endgroup$
    – dimus
    Commented Dec 15, 2013 at 17:14
  • $\begingroup$ @dimus This should probably be a separate question $\endgroup$
    – gandalf3
    Commented Dec 15, 2013 at 17:25
  • 1
    $\begingroup$ do you need an identifier, or do you actually need to store data per vertex? Basically, it's the same. Unfortunately, there's no way to run code on geometry add / remove, so it's hard to assign identifiers to a custom data layer as you edit the mesh. Note that custom data will be copied on mesh extrude etc., which would also copy a possible identifier, which is probably not what you want. $\endgroup$
    – CodeManX
    Commented Dec 15, 2013 at 22:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .