How to snap a part of a mesh into a part of another in Blender?

Is there the possibility in Blender to select some vertices (or faces) in mesh1, select some vertices (faces) on mesh2 and then snap the meshes by the vertices (faces)? I am thinking in complicated meshes generated by 3D scanning into an STL file.

• what do you mean by snapping? Do you mean lining up the two mesh so the median of the vertices selected in mesh1 has the same position as the median of the vertices selected in mesh2? Commented Feb 4, 2020 at 2:35
• Yes, more or less. What I want is a way to fit a mesh into another mesh. Let´s say you have a 3D scan of a piece that have a hole, because is broken. I need to design the missing part, so I need an object(mesh) that can fit in the missing hole. I´m not talking about holes in your mesh, but holes in a real life object. I´m thinking like a mechanical engineer using blender as a design tool instead of AutoCAD, for example. Commented Feb 7, 2020 at 21:00

This script only work on meshes with no rotation or scaling though.

import bpy
from mathutils import Vector
objAct = bpy.context.object
objsSel = bpy.context.selected_objects
midptAct = Vector((0, 0, 0))

# Calculate mid-point of selected vertices of the active object
for v in objAct.data.vertices:
if v.select:
midptAct += v.co
midptAct /= 4

# Calculate mid-point of selected vertices of the each selected object then move the object
for obj in objsSel:
if (objAct != obj): # since the active object is also inside the selected object list
midptSel = Vector((0, 0, 0))
for v in obj.data.vertices:
if v.select:
midptSel += v.co
midptSel /= 4
obj.location = objAct.location - midptSel + midptAct # moving the selected object


Select the vertices you want to perform snapping in both mesh. Select both mesh, and press Run Script, then the selected mesh will snap to the active mesh Is this the snapping you are looking for?