snap objects of same topology together by vertex index

does blender have the function of snapping objects of same topology together by vertex index? for example, take a simple cube A at origin and duplicate it as cube B, move it aside. now compare vertex index in cube A with cube B and move every vertex in cube A to cube B base on the index number.

it is simple to use modifier such as shrinkwrap and snap to closest vert option, but for more complex mesh, it is often misaligned to different vert on dense parts. hence I wonder if there is a way to do it via vert index.

I don't think there is something about that except Python.

This script will report vertex coordinates of active object to all the selected objects.

Version 1

Just give object the same topology:

import bpy

def snap_by_vertex_index(obj, target):
for o, t in zip(obj.data.vertices, target.data.vertices):
o.co = t.co

target = bpy.context.active_object

if target and target.type == 'MESH':
objects = [o for o in bpy.context.selected_objects if o.type == 'MESH' and o is not target]
for o in objects:
snap_by_vertex_index(o, target)


Version 2

Or, as suggested @batFINGER in comments, that can be moving vertices to the target:

import bpy

def snap_by_vertex_index2(obj, target):
mat = obj.matrix_world.inverted() @ target.matrix_world
for o, t in zip(obj.data.vertices, target.data.vertices):
o.co = mat @ t.co

target = bpy.context.active_object

if target and target.type == 'MESH':
objects = [o for o in bpy.context.selected_objects if o.type == 'MESH' and o is not target]
for o in objects:
snap_by_vertex_index2(o, target)

• Imagine this would require converting target to object space of obj. (and checking vert counts match) Nov 5, 2020 at 16:37
• @batFINGER, I know. But have considered the topology only here. But maybe you're right... just matrices product... Nov 5, 2020 at 16:39
• ok, will add it if you agree Nov 5, 2020 at 16:44
• I think so, going by question otherwise cubes A and B will stay in exactly the same locations Nov 5, 2020 at 16:47
• WOW~~~ that code works like a charm !!!!! thank you so very much !!! Nov 7, 2020 at 8:27