# How are vertex indices determined?

How does the program decide what indices to assign to vertices? If you create a primitive, are the indices generated randomly, or by some base primitive setting? If you extrude new vertices, will they be the next number in sequence?

What happens when you join two objects together that have the same indices used? Which points get reassigned, and by what logic? Can anything be done to control which get re-assigned?

Are there any ways to recalculate, re-assign, or copy vertex indices?

How does the program decide what indices to assign to vertices?

• new vertexes are appended to the end of the vertex list
• duplicating vertexes adds them also to the end and their order is maintained
• .. list too long..

It would be very time consuming to analyze every mesh operation/modifier and how it handles vertex indices and make a list for you (it will be like the above though in most cases if not in all). Instead you can reverse engineer this yourself:

Type bpy.app.debug = True into the Python Console

This will enable super top secret mode with next option available in Properties panel:

Now you can see the indices and how they change for what you are interested in:

Can anything be done to control which get re-assigned?

Nope, blender handles it internally.

Are there any ways to recalculate, re-assign, or copy vertex indices?

Sure, with python you can do anything to meshes, you can reorder the vertices. Just by building a new mesh with different vertex order from old one and then switching them.

• Is there a way to change the indices colors as well? The dark blue on a dark background is sometimes bad to read. Mar 23 '18 at 7:18
• @BrunoBieri Yes, you can go to UserPrefs > Themes > 3D View and change the Face Angle Text Color which these numbers use. Mar 23 '18 at 8:58
• It seems this has been moved to another place in Blender 2.8. Any ideas where I could find it? Apr 9 '20 at 12:24
• For Blender 2.8+ see blender.stackexchange.com/a/158495/1363 Jul 17 '20 at 16:14

Jerryno did a great job of explaining mesh indexes in his answer, so I will focus on:

Are there any ways to recalculate, re-assign, or copy vertex indices?

## Yes.

First let me clarify that there are more then just vertex indexes, faces and edges have indexes as well, but for the rest of this answer I will refer to just vertex indexes.

The simplest way to reorder the vertex indexes is with the Sort Mesh Elements tool, accessible from the 3D view header Mesh > Sort Elements. All the option in the dropdown menu run the same tool, and can be changed like any other operator by pressing F6 or in the Operator Properties section of the tool shelf.

If you want to do anything beyond reordering the indexes, that will require python.

• ...so, you select the mesh that has the "wrong" order, and a similar mesh with the target order, and do Edit (vertices) -> Mesh -> Sort Elements -> Selected? May 1 '20 at 23:36
• no it does not copy some other mesh's vertices' ids. To quote the manual "Selected Move all selected elements to the beginning (or end, if Reverse enabled), without affecting their relative orders. Warning: This option will also affect unselected elements’ indices!" AKA not what you want it to do. "Selected" simply renumbers the selected vertices so that they are at the beginning (or end with reverse enabled) of the indices. May 3 '20 at 2:07

You can also sort mesh elements with Python, using the bmesh module:

import bpy
import bmesh
import random

ob = bpy.context.object
assert ob.type == "MESH"
me = ob.data

bm = bmesh.from_edit_mesh(me)
new_order = list(range(len(bm.verts)))
random.shuffle(new_order)

for i, v in zip(new_order, bm.verts):
v.index = i

print("shuffled indices:")
for v in bm.verts:
print(v.index)

print("update index()")
bm.verts.index_update()

print("indices returned to original order:")
for v in bm.verts:
print(v.index)

print("shuffling again, followed by a sort:")
for i, v in zip(new_order, bm.verts):
v.index = i
bm.verts.sort()

for v in bm.verts:
print(v.index)

bmesh.update_edit_mesh(me)


It's important to call sort() after assigning new indices to actually apply the new order. After that, indices will be ordered 0..n, but if you check the indices drawn in viewport, then you'll see that they changed.

• Will this re-order to 0..1..2..3..4..5..n incrementally? Some game engine don't accept face indices and just programatically generate it incrementally on run-time. May 17 '17 at 17:51
• Not sure what you mean by incrementally... If you export from Blender after sorting, the indices should be in that order. I don't think that holes (e.g. 0, 2, 3, ...) are allowed in Blender. May 18 '17 at 15:47
• I asked a question about that here. Can you check? :) blender.stackexchange.com/questions/79805/re-arranging-vertices May 18 '17 at 16:21
• @CoDEmanX Its a nice script that shuffles the verices. What do i need to change to sort the list from smallest to biggest? i tried sorted(new_order) but did not worked
– DGRL
Dec 30 '19 at 11:17
• @DGRL Smallest to biggest what? Dec 31 '19 at 12:40

For whoever will find this helpful, here is how to display vertex indices in 'Blender 2.80':

1. In Preferences - Interface - Display, check 'Developer Extras'.

2. In the 3D View - Overlays, there should now be a 'Developer' section, check its "Indices" box - see screenshot below:

• thanks for the answer. I am able to do Step 1, but how do you do Step 2? I do not see an option for "3D View" to click. Apr 22 '20 at 23:26
• I just added a screenshot, hope that helps. Apr 24 '20 at 9:56
• Also, don't forget to check "Text info" in the same panel, for some reason it is unchecked by default (on my end at least) Apr 24 '20 at 10:04
• Thanks! (I am using Blender 2.8+ but hopefully the interface is similar -- let me check!) Apr 24 '20 at 15:56
• Is it possible to change the font, size and color of the index overlay? It's very difficult to read. Sep 30 '20 at 16:05