The "Clean up" toolbox can detect non-planar faces and split them. But I'd like to have a way to view them first! Is there an easy method of mass-selecting non-planar faces (like a trait selection)?
Thanks in advance, I hope someone helps me out!
The "Clean up" toolbox can detect non-planar faces and split them. But I'd like to have a way to view them first! Is there an easy method of mass-selecting non-planar faces (like a trait selection)?
Thanks in advance, I hope someone helps me out!
Here is a script to run in edit mode, It looks at all faces with > 3 vertices, defines a plane from the first 3 verts [v.co for v in ngon.verts[:3]]
as input coords to determine its normal and ngon.verts[0].co
is a point on the plane
If absolute distance from rest of vertices in ngon to defined plane is less than some tolerance the face is planar.
import bpy
import bmesh
from mathutils.geometry import (
distance_point_to_plane,
normal)
context = bpy.context
obj = context.edit_object
mesh = obj.data
TOL = 0.001
# select None
bpy.ops.mesh.select_all(action='DESELECT')
bm = bmesh.from_edit_mesh(mesh)
ngons = [f for f in bm.faces if len(f.verts) > 3]
for ngon in ngons:
# define a plane from first 3 points
co = ngon.verts[0].co
norm = normal([v.co for v in ngon.verts[:3]])
ngon.select = not all(
[abs(distance_point_to_plane(v.co, co, norm)) < TOL
for v in ngon.verts[3:]])
bmesh.update_edit_mesh(mesh)
Result of running script with TOL = 0.1 on mesh made of cylinder, uv sphere, torus and monkey primitives.
Meanwhile the 3D-Print Toolbox provides this functionality out of the box:
Mesh: 3D-Print Toolbox
N
-panel3D-Print
tabCheck-All
(or Distorted
under Checks)Non-Flat Faces
button.