8
$\begingroup$

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!

$\endgroup$
1
  • $\begingroup$ Could you add a screencapture of your mesh? $\endgroup$ Commented Dec 21, 2016 at 11:23

2 Answers 2

5
$\begingroup$

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.

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you for the script, I ran it but sadly it didn't help the cause much. Reason being - it selects way more faces that it thinks are non-planar, but at the same time Blender's cleanup finds far less of those. $\endgroup$
    – eigos
    Commented Dec 21, 2016 at 14:22
  • $\begingroup$ The script has a tolerance TOL which is the distance from the vert to the "face plane", just like split non planar faces operator has an angle_limit (default 5 degs). Perhaps I could change up to check angle rather than distance to match clean up. Added a pic of result of running script using TOL = 0.1. It selects pretty much all the monkey if TOL = 0.00001 and none of the others. It selects no faces after "split non planar faces" clean up.... I'm happy with it. $\endgroup$
    – batFINGER
    Commented Dec 21, 2016 at 17:58
  • 1
    $\begingroup$ Very interesting, great answer. $\endgroup$
    – J Sargent
    Commented Dec 22, 2016 at 4:06
2
$\begingroup$

Meanwhile the 3D-Print Toolbox provides this functionality out of the box:

  • activate the add-on Mesh: 3D-Print Toolbox
  • select your object
  • open the N-panel
  • click the 3D-Print tab
  • click Check-All (or Distorted under Checks)
  • make sure you are in edit mode
  • click the Non-Flat Facesbutton.

screenshot of 3D-Print Toolbox

$\endgroup$

You must log in to answer this question.

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