# How to merge two unconnected edges into a single one

There are several questions on merging connected edges and edge loops, but I can't find the simplest case where we just have two edges:

and want them to be merged like this:

I don't have a requirement on the location of the final edge, but I guess a comprehensive answer would encompass the different possibilities: merging at active edge or at mid-distance.

I know I can:

• move a vertex onto the other using the snap option,
• select the four vertices,
• remove the two doubles.

But that's four operations. Can it be done more quickly?

• The steps are pretty quick ... I suppose there is no quicker way as far as I know. unless you want to write a script with a shortcut attached to it. – hawkenfox Jan 14 '16 at 8:13
• It looks like you want a script that will take two edges into account, the vertices of the selected edge should move towards the closest vertices of the active edge. ? – zeffii Jan 14 '16 at 8:23
• I would simply use snapping tools – m.ardito Jan 14 '16 at 9:33
• Same as here: blender.stackexchange.com/questions/44308/… – stacker Jan 14 '16 at 9:58

Maybe this is a little faster ... hmmm But you will have to turn on the addon called "F2"

1. Select the 2 edges.
2. Hit F, connects the 2 mesh and gives you 2 original edges.
3. Select the extra edge you didn't need. Hit X dissolve the edge.

There is also the option:

• Select both edges
• CtrlE > 'Bridge Edge Loops', with 'Merge' checked.

The 'Merge' option will remain checked for repetitions of the operation.

If 'Loop Pairs' is also checked, the move can be made on multiple pairs of edges simultaneously.

Just select one vertex from each edge, hit Alt + M > Merge at first or at center, then do the same with the other two vertices and it is done.

This way yo just make 2 steps each vertice.

• Your answer is fine, but a Screenshot or GIF would go a long way in making it clearer. – Ben May 8 '19 at 6:38
• Thanks, i didn't thought about that. – Maurice May 19 '19 at 17:20

It looks like you want a script that will take two edges into account, the vertices of the selected edge should move towards the closest vertices of the active edge.

In code that looks like:

# This example assumes we have a mesh object in edit-mode

import bpy
import bmesh
from bmesh.types import BMEdge

def move_edge_verts(obj):
me = obj.data
bm = bmesh.from_edit_mesh(me)

# get active edge or return early
active = bm.select_history.active
if not isinstance(active, BMEdge):
print("no active edge")
return

av1, av2 = active.verts[:]

# get first selected edge that isn't active
selected = None
for e in bm.edges:
if e.select and not e.hide:
if e == active:
continue
selected = e
break

if not selected:
print('no selected verts beyond the active edge')
return

# find corresponding verts and move
sv1, sv2 = selected.verts[:]

if (sv1.co - av1.co).length <= (sv1.co - av2.co).length:
sv1.co = av1.co.copy()
sv2.co = av2.co.copy()
else:
sv1.co = av2.co.copy()
sv2.co = av1.co.copy()

d = 0.0001
bmesh.ops.remove_doubles(bm, verts=[sv1, sv2, av1, av2], dist=d)

# Show the updates in the viewport
# and recalculate n-gon tessellation.
bmesh.update_edit_mesh(me, True)

# Get the active mesh
obj = bpy.context.edit_object
move_edge_verts(obj)


it could have many improvements; like dropping the remove doubles step and updating the edge vertex indices to use the existing indices of the active edge instead.

note:
However -- there is an obvious potentially false assumption here, the corresponding vertex on the other edge might not be the closest. A solution is to make the geometry less ambiguous or improve the closest point search algorithm

for example the scenario on the left is obvious to us, and the algorithm will get it right because the corresponding vertices on both edges are nearer their counterparts.

The example on the right will get results depending on which vertex index is looked at first, can work, can fail. Obvious to our eyes, not so obvious to the dumb algorithm I use above.

It's actually easy you can simply

1. select both vertices
2. press "W" which brings up the specials menu
3. then select "Merge" or simply skip step 2 and hit "alt+M" from the get go
4. lastly select any of the options like "At First" and they're merged at the point of the first vertex you selected.

If you press F you're creating a new face and you're basically taking the long way about this issue. Both ways work but you're making more trouble for yourself that way and potentially developing bad habits.

Now in Blender 2.83, select vertices to join in edit mode (use vertex selection). Then simply press M for merge (Alt-M does a split now), then merge centre.