Skip to content

Instantly share code, notes, and snippets.

@CGLion
Last active October 4, 2020 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CGLion/8cedb6f6f5edeaedfb5fbaf7f2f60f2d to your computer and use it in GitHub Desktop.
Save CGLion/8cedb6f6f5edeaedfb5fbaf7f2f60f2d to your computer and use it in GitHub Desktop.
Python for Blender - Access mesh triangles
import bpy
mesh = bpy.context.active_object.data
mesh.calc_loop_triangles()
for tri in mesh.loop_triangles:
tri_center = (mesh.vertices[tri.vertices[0]].co * 0.333) +\
(mesh.vertices[tri.vertices[1]].co * 0.333) +\
(mesh.vertices[tri.vertices[2]].co * 0.333)
bpy.ops.mesh.primitive_uv_sphere_add(radius=0.1,enter_editmode=False,location=tri_center)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment