How can I select all verts that has 4 edges connected to it? I need to get the “intersecting” verts. I figured the best way is to check if it has 4 edges connected.
Something maybe like the following:
cube = bpy.context.active_object bm = bmesh.from_edit_mesh(cube.data) # Find all verts with exactly 4 edges coming into it verts4 = [v for v in bm.verts if len(v.link_edges) == 4] # i.e. using > 5 above will find you all of the nasty 6-poles in your topology etc.
How can I only select the ones visible? If I hide parts, it still selects verts that has 4 edges even if it’s hidden.
What gets selected
What I need
Maybe this floats your boat?
import bpy import bmesh aob = bpy.context.active_object # 3D viewport should be in object mode if not aob.mode == 'OBJECT' : bpy.ops.object.editmode_toggle() fmesh = bmesh.new() fmesh.from_mesh(aob.data) # Ensure bmesh internal index tables are fresh fmesh.verts.ensure_lookup_table() fmesh.edges.ensure_lookup_table() fmesh.faces.ensure_lookup_table() # cand: verts member of exactly four edges and visible cand = [v for v in fmesh.verts if v.hide == False and len(v.link_edges) == 4] pick = list() # Select candidates with all four neighboring vertices also visible for v in cand : somehidden = False for e in v.link_edges : somehidden = somehidden or e.other_vert(v).hide if not somehidden : v.select_set(True) pick.append(v) else : v.select_set(False) # Sync up bmesh and mesh fmesh.to_mesh(aob.data)