I have this mesh:

enter image description here

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°):

enter image description here

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

enter image description here

(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.


1 Answer 1


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 math import radians
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:
    v.select = len(v.link_edges) == 5

test_angle = radians(50)
# select edges on face angle
for e in bm.edges:
    if e.is_boundary:
    # 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.

  • $\begingroup$ 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... $\endgroup$
    – Kabu
    Mar 23, 2018 at 21:09
  • $\begingroup$ just a couple of typos... too many radians and testangle $\endgroup$
    – Kabu
    Mar 23, 2018 at 21:11
  • $\begingroup$ @Kabu Thanks, edited. Changed from hard coding 50 3 times as an afterthought when posting. $\endgroup$
    – batFINGER
    Mar 24, 2018 at 3:43

You must log in to answer this question.

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