# How to get all faces based on a certain angle of their normals?

I would like to create a list of faces/polygons based on the angle of each corresponding normal. I've tried something like board.data.polygons[0].normal > 0, but that doesn't seem to work.

Question: How to pick the normals that are pointing downwards (-z axis) and append their associated faces/polygons to a new list?

Use Vector.angle(Vector)

To get all normals that are within 89 degrees of the -z axis in local space (down = Vector((0, 0, -1)) use face.normal.angle(down) which calculates the angle between the face normal and the local vector pointing down.

import bpy
from mathutils import Vector
context = bpy.context
obj = context.object
me = obj.data
down = Vector((0, 0, -1)) #  -z axis.
# list all faces with normal less than 89 degrees to down
faces = [f for f in me.polygons
if f.normal.angle(down) < test_angle]

print(faces)


Change the test_angle value to suit.

board.data.polygons[0].normalreturns a vector(x,y,z). You need to choose the axis you want to compare in your case "Z". So:

board.data.polygons[0].normal[2] < 0:
#do something here


Note if you only want the faces pointing directly down, you have to compare to -1.0(board.data.polygons[0].normal[2] == 1.0)

• IMO never use equality (x == 1.0) with floats, always use a tolerance. abs(x - 1.0) < TOL Commented Dec 8, 2017 at 3:07