# How to select a mesh peaks and troughs

I have this mesh:

With a python script, I'd like to select the peak and / or the hole. I put them together because it looks like the solution is the same... More exactly I'm looking for a way to tell those features apart from the rest of the mesh... Blue selected edges show the (hypothetical) boundaries. Feels like it's something related to curvature, but not sure...

EDIT: result by selecting edges at angles (50°):

faces selection (vector (0,0,1)):

(I don't understand this) EDIT: now I got it. It requires a more precisely oriented vector to tell faces by angles. Gotta look for this better.

Face normals, Edge angles, and link edges count.

In your screenshot the peaks and troughs are extrusions which have a vertex edge count of 5, which is a simple test.

Can also look at the signed edge angle to find peaks and troughs. I've used 50 degrees.

And also look at face normals vs an up vector. (A simple z axis to test)

Test script run in edit mode.

import bpy
import bmesh
from mathutils import Vector

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

up = Vector((0, 0, 1))

#  because its an extrusion select on link edges
for v in bm.verts:

# select edges on face angle
for e in bm.edges:
if e.is_boundary:
continue
# hills
e.select = ( e.calc_face_angle_signed() > test_angle
# troughs
or e.calc_face_angle_signed() < test_angle

for f in bm.faces:
f.select =  f.normal.angle(up) > test_angle


Some combination of any or all of the tests above should cover most cases.

• f.normal.angle(up) > radians(testangle) -> this gives the angle between the normal and the "up" vector... I don't understand what value to give to "up" for the test to work...
– Kabu
Mar 23, 2018 at 21:09
• just a couple of typos... too many radians and testangle
– Kabu
Mar 23, 2018 at 21:11
• @Kabu Thanks, edited. Changed from hard coding 50 3 times as an afterthought when posting. Mar 24, 2018 at 3:43