1
$\begingroup$

I've got a not flat surface with not regular faces. Is there a way to recognize if there is a hole at a set circumference?

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

You can take advantage of the fact that holes are also non-manifold to easily identify hole vertices that lie within a given radius from the selected face.

enter image description here

Here's the code:

import bpy, bmesh

radius = 0.5

# Assumes your object is selected and is in edit mode
o  = bpy.data.objects[ bpy.context.object.name ]
bm = bmesh.from_edit_mesh( o.data )

# Assumes you have a single face selected
fCo = bm.select_history[0].calc_center_median() # Location of face center

bpy.ops.mesh.select_all( action = 'DESELECT' )
bpy.ops.mesh.select_mode( type = 'VERT' )
bpy.ops.mesh.select_non_manifold() # Holes are also non-manifold

# Find all hole verts that are closer to the selected face than the radius
verts = [ v for v in bm.verts if v.select and ( fCo - o.matrix_world * v.co ).length < radius ]

if len( verts ) > 0:
    print( "%s hole verts within radius of %s blender units" % ( len( verts ), radius ) )

bpy.ops.mesh.select_all( action = 'DESELECT' )
for v in verts:
    v.select = True

bm.select_flush( True )
$\endgroup$
0

You must log in to answer this question.

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