1
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ 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? $\endgroup$
    – covector
    Commented Feb 4, 2020 at 2:35
  • $\begingroup$ 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. $\endgroup$
    – Alejandro
    Commented Feb 7, 2020 at 21:00

1 Answer 1

0
$\begingroup$

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. selecting Select both mesh, and press Run Script, then the selected mesh will snap to the active mesh run script Is this the snapping you are looking for?

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .