I have some selected vertices that forms a loop,This loop may be disconnected or connected to other faces: Example

I want to check if it is disconnected or not using python.


2 Answers 2


enter image description here This will do the trick in your case:

import bpy, bmesh

bm = bmesh.from_edit_mesh( bpy.context.object.data )

selectedVerts = set( [ v.index for v in bm.verts if v.select ] )

bpy.ops.mesh.select_all( action = 'DESELECT' )

nonManifoldVerts = set( [ v.index for v in bm.verts if v.select ] )

commonVerts = selectedVerts.intersection( nonManifoldVerts )

bpy.ops.mesh.select_all( action = 'DESELECT' )
for i in selectedVerts: bm.verts[i].select = True
bm.select_flush( True )

msg = "Not connected" if commonVerts else "Connected"
print( msg )


This will now work with any loop that is completely manifold (i.e doesn't have any non-manifold edge/vert)

  • 1
    $\begingroup$ Well,I don't expect the user to always use a quad object,Is there is anyway it can be done universally? There is an operation for blender called select non manifold which select all disconnected vertices,You think we can use it to see if it is or not? $\endgroup$
    – Omar Emara
    Jun 28, 2016 at 15:07
  • $\begingroup$ Yeah that angle works better, updated the script. $\endgroup$
    – TLousky
    Jun 28, 2016 at 15:20

could be a detail but in a more advanced script maybe you need to keep the order of selection and the active vertex (last selected)

import bpy,bmesh

cao = bpy.context.active_object
bm = bmesh.from_edit_mesh(cao.data)

verts_list=[v for v in bm.verts if v.select]

def disconnected(verts_list):
    history = bm.select_history[:] #bmesh selection history copy
    bpy.ops.mesh.select_all(action = 'DESELECT')
    nonManifoldVerts={v for v in bm.verts if v.select}
    selectedVerts = set(verts_list)

    commonVerts = selectedVerts.intersection(nonManifoldVerts)

    bpy.ops.mesh.select_all(action = 'DESELECT')
    for v in verts_list: 
        v.select = True
    bm.select_history=history #first order of selection back

    if commonVerts:
        return True


disconnected = disconnected(verts_list)
print("disconnected", disconnected) #True/False
  • 1
    $\begingroup$ Thanks for the answer. Could you explain what this code does and why it helps? $\endgroup$ Oct 1, 2020 at 21:49

You must log in to answer this question.

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