# Fill a face with evenly distributed triangles

Is there a way to fill an ngon with Tri's, a way to automate an operator to achieve the image on the right, it should also keep the borders untouched:

• Could try quad fill. ie after easy bit of removing internal geometry, leaving just boundary edges, make an edge from top to bottom with enough verts such that region boundary is multiple of 4 and quad fill. ... or similarly with inset & quad fill. Jul 12 at 14:37
• can you upload your blender file ? Jul 12 at 14:50

As in this thread: blenderartists.org: Triangle Fill Addon Update For Blender 2.80, you can use Petteri Aimonen’s Triangle Fill add-on (direct link to v 2.8). There's also another add-on mentioned in the thread, Tom Svilans' Delaunay Triangulator (Github link), which is a Python wrapper of a C library - sadly it no longer works in Blender 2.8, but I put instructions how to make it work at the bottom.

Comparison:

• leftmost: Petteri's solution is straight-forward, N Numbers Panel > Tools tab;
• rightmost: grid fill will depend on mesh, you can enable statistics in Viewport Overlays then remove/add vertices (XD Dissolve / CtrlR Loop Cut) until their number is divisible by 4, then grid fill, maybe some loopcuts, CtrlT Triangulate;
• middle: Svilan's add-on - as I said, it doesn't work; unfortunately I'm not into add-ons, but I migrated the heart of the add-on to 2.8 so it can be used without interface - just paste the code below to Scripting tab, modify the first line to change options, then save the script to the folder with the rest of the add-on files and run it (with objects selected):
args = "pq20a1ziV"

"""

http://tomsvilans.com

A Python wrapper / Blender add-on for Triangle:

/*  A Two-Dimensional Quality Mesh Generator and Delaunay Triangulator.      */
/*  (triangle.c)                                                             */
/*                                                                           */
/*  Version 1.6                                                              */
/*  July 28, 2005                                                            */
/*                                                                           */
/*  Copyright 1993, 1995, 1997, 1998, 2002, 2005                             */
/*  Jonathan Richard Shewchuk                                                */
/*  2360 Woolsey #H                                                          */
/*  Berkeley, California  94705-1927                                         */
/*  jrs@cs.berkeley.edu                                                      */

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

"""

import bpy, bmesh
from mesh_triangle.triangle import triangulate

C = bpy.context

def get_nonmanifold_edges(mymesh):
culprits=[]
for e in mymesh.edges:
shared = 0
for f in mymesh.polygons:
for vf1 in f.vertices:
if vf1 == e.vertices[0]:
for vf2 in f.vertices:
if vf2 == e.vertices[1]:
shared = shared + 1
if (shared > 2):
culprits.append((e.vertices[0], e.vertices[1]))
if (shared < 2):
culprits.append((e.vertices[0], e.vertices[1]))
return culprits

def triangulate_object(obj_in, args):
mesh_in = obj_in.to_mesh()  # pre 2.8 args: (bpy.context.scene, True, 'RENDER')
verts = [x.co for x in mesh_in.vertices]
Nv = len(verts)
faces = [[y for y in x.vertices] for x in mesh_in.polygons]
border = get_nonmanifold_edges(mesh_in)

#if ('v' in args or 'D' in args):
#    return triangulate(verts, faces, border, args, True)[1]
res = triangulate(verts, faces, border, args)
return (res[0], res[1], Nv)

bm = bmesh.new()
for v in verts:
bm.verts.new(v)
bm.verts.ensure_lookup_table()

for f in faces:
bm.faces.new([bm.verts[x] for x in f])
bm.faces.ensure_lookup_table()
bm.verts.index_update()

m = bpy.data.meshes.new(mesh_name)
bm.to_mesh(m)
bm.free()

o = bpy.data.objects.new(obj_name, m)

return o

def main():
for o in C.selected_objects:
(verts, faces, N) = triangulate_object(o, args)
obj = add_mesh(verts, faces, o.data.name + '_triangulated', o.name + '_triangulate')

original_verts = [x for x in obj.data.vertices[:N]]
vg = obj.vertex_groups.new(name="Triangle Boundary")
for v in original_verts:
v.select = True

obj.matrix_world = o.matrix_world

main()

• Sorry for the aliasing on edges, I didn't predict that scaling artifact. Jul 15 at 12:05

Vanilla Blender 2.93