
You will see a new object has been added but there’s no geometry to be seen (since we haven’t added it yet). Check the API Docs for more info on this function Note that If you pass a faces list you can skip edges. This function creates a mesh from three python lists: vertices, edges and faces. The most interesting part is from_pydata(). I’ve also added some empty lists for verts and faces. We have to add a mesh datablock first, then an object that uses that mesh and finally link them to the current scene. Next we set up the mesh and object adding part. Name will be both the mesh and object’s name, while rows and columns will control how many vertices the grid has. Let’s start by importing bpy (surprise!) and setting up some variables.

We have to add a mesh and link it to an object, and then link that object to a scene before we can see any results. The Blender data system makes a distinction between mesh data and objects in the scene. Pro Tip: Save often while working on meshes! You will make Blender crash more than once 🙂 Tutorial Series For this introduction we’ll skip the 3D and focus on making a simple flat grid instead. I’m assuming you already know some basic Python, and enough Blender to get around.

In this series we will be looking at making several primitives and some basic transformations, I’ll also drop some tips along the way to make development easier. Blender is a great choice for this kind of work since it combines a full blown modeling and animation suite with a powerful (and fairly well documented) Python API. You can create parametric objects that respond to real world settings, generative art, math based shapes or even procedural content for games. Procedural generation is awesome! In this tutorial series we’ll look at making meshes using Blender’s Python API.Ĭreating meshes programmatically opens many possibilities.

Meshes with Python & Blender: The 2D Grid
