Blender Stack Exchange is a question and answer site for people who use Blender to create 3D graphics, animations, or games. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to associate a custom tag with each vertex?

I would like to be able to number them...

I have an export script that dumps 6000 vertices to file, I then run a simulation that generates an array for each vertex.

But I would like to be able to give each vertex a unique ID as it is written to file, so that I can select a dozen vertices in blender, and export a list of IDs (and then process the array for each)

How can I do this?


share|improve this question
Tell me if I'm wrong, but can't you use vertex groups or just the active selection? With vertex groups, you would assign vertices to be exported to groups, and export one or many groups by script. You could either enumerate the verts or use their indices, but can't see a reason to store an ID for every vert in Blender. Active selection: you would export verts if .... – CoDEmanX Feb 17 '14 at 13:02
If it was only one object then the vertex indices would be unique. But it is several objects... – P i Feb 17 '14 at 15:29
Count the vertices for the objects. Create an index for the objects defining an order. For the first object the vertex indices begin with 0. For the second object you simply add the vertex count of the previous object to the indices. And so on... – pink vertex Feb 17 '14 at 19:31

It is possible to tag vertices with the bmesh module:

bm = bmesh.from_edit_mesh(
bm =

#create custom data layers
my_id ='id')

#get the custom data layer by its name
my_id =['id']

bm.verts[0][my_id] = 42

#apply the changes
share|improve this answer
IDs won't stay unique as soon as you extrude or do similar operations on the mesh. If IDs are needed for the export only, then they shouldn't be stored as custom data - it's unnecessary and quite slow. – CoDEmanX Feb 17 '14 at 13:32
It is possible to tag vertices. I just answered the first question present in the caption which may be searched by other people. He has been warned now that it may not be a good solution to his problem. – pink vertex Feb 17 '14 at 19:51
Thanks for this topic. And how to remove the custom property 'my_id' from all verts? – mifth Jun 2 '15 at 11:15
I asked new question here… – mifth Jun 2 '15 at 14:59
How can I access these custom data layers again when I only have a mesh? – Ray Koopa Jun 20 at 22:16

You can count vertices on export and use that instead of the vertex indices:

import bpy

c = 0

for ob in bpy.context.scene.objects:
    if ob.type == 'MESH':
        me =
        print("Mesh %s (%s):" % (,

        for i, v in enumerate(me.vertices, c):
            print("  Vert %i - %i" % (i, v.index))
        c += len(me.vertices)

And here all selected verts of all mesh objects in scene:

# Simple

def count_selected_verts(file):
    c = 0

    for ob in bpy.context.scene.objects:
        if ob.type == 'MESH':
            if ob.mode == 'EDIT':
            me =
            file.write("Mesh %s (%s):" % (,

            for v in me.vertices:
                    file.write("%5i - Vert %i\n" % (c, v.index))
                    c += 1
# Pythonic - generator and list comprehension with a hacky filter

# This is infinite, don't cast to sequence!
def countup():
    i = 0
    while True:
        yield i
        i += 1

def ob_update(ob):
    # Prints all mesh objects at the top of the file :/
    #file.write("Mesh %s (%s):" % (,
    if ob.mode == 'EDIT':
    return True

def count_selected_verts_gen(file):
    c = countup()
    for ob in bpy.context.scene.objects:
        if ob.type == 'MESH' and ob_update(ob):
            file.write("Mesh %s (%s):" % (,
            file.write("\n".join("%5i - Vert %i" % (c.__next__(), v.index)
                for v in if

I compared the performance: 22.0 vs. 9.4 secs (pythonic is win!).

share|improve this answer
But how can I select a vertex in blender and match it to the appropriate entry in the output file? – P i Feb 17 '14 at 17:48
What do you mean by 'match'? I posted another script to enumerate all selected verts of all meshes, is that what you need? – CoDEmanX Feb 18 '14 at 1:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.