Reputation: 1714
What is a clean way to create a procedural mesh in blender with a script? Ideally I'd like to create an empty mesh and start adding vertices and triangles, like this:
mesh = create_mesh()
a = mesh.add_vertex([0, 0, 0])
b = mesh.add_vertex([1, 0, 0])
c = mesh.add_vertex([1, 1, 0])
t = mesh.add_triangle(a, b, c)
Upvotes: 0
Views: 1675
Reputation: 7079
Blenders bmesh module is designed for creating and editing mesh data, although you can also turn python arrays into mesh data.
You can find some examples included with blender, all addons are made using python, one helpful addon would be add_mesh_extra_objects
which has several examples of creating different types of objects.
There is a blender specific stackexchange site where you will get more help with blender specific scripting. You should also find some existing examples there.
Upvotes: 1