I'm new around here. I wanted to ask if there is any way to order the vertex index in this way? 
2 Answers
Bmesh version
Here is a bmesh version of @3fingeredfrog's answer using method suggested here https://blender.stackexchange.com/a/36619/15543
Orders based on distance from scene cursor.
import bpy
import bmesh
context = bpy.context
scene = context.scene
ob = context.edit_object
mw = ob.matrix_world
cloc = mw.inverted() @ scene.cursor.location
me = ob.data
bm = bmesh.from_edit_mesh(me)
#bm.verts.ensure_lookup_table()
verts = sorted(bm.verts, key=lambda v: (v.co - cloc).length)
for i, v in enumerate(verts):
v.index = i
bm.verts.sort()
bmesh.update_edit_mesh(me)
Could maually select all vertices in order (one by one) and retrieve from the select history
verts = [e for e in bm.select_history if isinstance(e, bmesh.types.BMVert)]
The order in question appears to be that next is furthest of all the connected verts if not visited.
- 84,216
- 10
- 108
- 233
In this particular case, yes, by ordering the index number of each vertex relative to its distance from the 3D cursor.
1: From the Viewport Overlays menu > Developer > enable the Indices option. The index number of each selected vertex will now be displayed in blue.
2: Position the 3D Cursor so that it is closest to "v1" and "v2" is the next closest ..........
3: In Edit mode and with the vertices selected: open the Mesh menu > Sort Elements > choose the Cursor Distance option.
now v1=0 v2=1 v3=2 v4=3 etc
- 5,670
- 9
- 12
-
Good answer, but the questions tag says scripting. Do you have any input on a scripting approach? E.g. how to position the 3D Cursor and call that operation with python? – Leander May 14 '20 at 10:15
-
oppps, I missed that @Dark -Z was looking for a scripting solution and have no idea how to do that with python. – 3fingeredfrog May 14 '20 at 10:21
-
thanks for the information, I work by doing it manually but do not know of the existence of any python script that does this job? – Dark -Z May 15 '20 at 19:10
-
I need a script because there are many mesh that I need to order the index – Dark -Z May 15 '20 at 19:11


