I'm currently modifying a mesh using a Python script. I just realised that my mesh have a few t-junctions, which I would like to fix. Is there any way to fix t-junctions in Blender? If so, is it also possible to do this from script?

Clarification: My mesh contains t-junctions where the vertices are disconnected from the opposite face. A script or Blender feature that just 'glues'/connects the vertex would also work fine for me.

enter image description here

  • 2
    $\begingroup$ see if this helps T-Junction-remover $\endgroup$
    – Chebhou
    Mar 28, 2015 at 15:02
  • $\begingroup$ The script is quite old and doesn't run on the current Blender version. I was hoping to find some off-the-shelf solution that worked out of the box. (If not, I have a few ideas of how to make such script myself) $\endgroup$ Mar 28, 2015 at 15:34

1 Answer 1


I came up with the solution below, which seems to work. Generally I just create faces in the holes (the black on the figure above) and finally dissolve degenerate (since the newly introduced faced has the area of zero).

import bpy
import bmesh
from math import radians, degrees, pi, atan2
from mathutils import Vector, Euler

def isEdgesOverlapping(v, e1, e2):
    if e1 == e2:
        return False
    v0 = v.co
    v1 = None
    v2 = None
    if (e1.verts[0] == v):
        v1 = e1.verts[1].co
        v1 = e1.verts[0].co
    if (e2.verts[0] == v):
        v2 = e2.verts[1].co
        v2 = e2.verts[0].co
    dir1 = (v1 - v0).normalized()
    dir2 = (v2 - v0).normalized()
    if dir1.cross(dir2) < 0.00001 and dir1.dot(dir2) > 0.5:
        return True
    return False

def fixTJunctions2(bm): 
    for e in bm.edges:
        e.select = False
    for v in bm.verts:
            for e1 in v.link_edges:
                for e2 in v.link_edges:
                    if isEdgesOverlapping(v, e1, e2):
                        e1.select = True
                        e2.select = True
                        return True
    return False   

def fixTJunctions(obj):
    if bpy.context.mode == 'OBJECT':
        bpy.ops.object.mode_set(mode='EDIT', toggle=True)
    bm = bmesh.from_edit_mesh(obj.data)
    for e in bm.edges:
        e.select = False    
    continueLoop = True 
    count = 0
    while continueLoop:
        continueLoop = fixTJunctions2(bm)
        count = count + 1
    if count > 1:

obj = bpy.context.active_object 

You must log in to answer this question.

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