Created
October 3, 2015 08:16
-
-
Save zeffii/20752881b72e697bddc5 to your computer and use it in GitHub Desktop.
find tris and non planar poygons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This example assumes we have a mesh object selected | |
import bpy | |
import bmesh | |
import mathutils | |
from mathutils import Vector | |
tessellate = mathutils.geometry.tessellate_polygon | |
normal_of = mathutils.geometry.normal | |
mesh = bpy.context.object.data | |
for f in mesh.polygons: | |
if len(f.vertices) == 3: | |
f.select = True | |
continue | |
# 4 or more vertices. let's check coplanarity by | |
v = [mesh.vertices[i].co for i in f.vertices[:]] | |
start_normal = Vector() | |
for idx, pol in enumerate(tessellate([v])): | |
vectors = [v[i] for i in pol] | |
if idx == 0: | |
start_normal = normal_of(vectors) | |
else: | |
if (start_normal-normal_of(vectors)).length > 0.002: | |
f.select = True | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment