1
$\begingroup$

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?

$\endgroup$
0
$\begingroup$

There is an existing operator for this: Select Similar (Shift-G).

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.

bpy.ops.mesh.select_similar(type='AREA', threshold=0.5)

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.

| improve this answer | |
$\endgroup$
1
$\begingroup$

Bmesh Version

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)

enter image description here A run on Suzie

| improve this answer | |
$\endgroup$
  • $\begingroup$ I appreciate this input greatly. Time to get some hands-on scripting! $\endgroup$ – Abedd Jun 24 '18 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.