I have a complex mesh that I want to select its "large" faces only, as the mesh has considerably large faces and much smaller ones. Is there a way I can write a script to select faces that are larger than a certain amount in Blender, Imperial, or Meter units?
There is an existing operator for this: Select Similar (
Select one of the larger faces, then do Select Similar > Area. Then press
F6 to adjust the threshold until all the faces you want are selected.
If you need to do this with Python, one option would be to just call the operator directly, though finding the exact threshold programmatically may be tricky.
Note that calling operators in python is not really best practice. If you want to do it properly, you'll have to get all the faces and coordinates of their vertices and calculate the area yourself.
Simple test script, run in edit mode. Rather than a particular size, which is a little tricky once scale is involved, for example sake, selects faces 6 x larger than average face area. ... find the max, and select all faces over a certain percentage of that or.... use the sorted list to select n biggest etc etc.
Note this doesn't take into account mesh deformed by modifiers.
import bpy import bmesh context = bpy.context FACTOR = 6 ob = context.edit_object me = ob.data bm = bmesh.from_edit_mesh(me) avg_face_area = sum(f.calc_area() for f in bm.faces) / len(bm.faces) print("avge face area: ", avg_face_area) # biggest is last member of faces sorted #faces = sorted(bm.faces, key=lambda f: f.calc_area()) for f in bm.faces: f.select = f.calc_area() > FACTOR * avg_face_area bmesh.update_edit_mesh(me)