How Mesh data + Displacement Data = Animation

I am new to Blender. However, I’ve used it for several months. I am good at python scripting. I understand basics of Blender.

Ok, let me tell you what I’ve got so far and what is left to do that I am having difficulties in.

I want to create an animation of mathematical model. I have imported the initial data (9000 triangles). Everything looks good.

Now, I am trying to apply displacements on the vertexes to animate. I want to keep everything as one object because later I might change camera location and coloring, etc. I also wanna be able to apply interpolation if between displacement data because I might not have enough frames.

Would anyone guide me on how I can accomplish this through python scripting, please?


First off, familiarise youself with the Python API of Blender, especially the Mesh module, although you could also use the NMesh.

Here is a link to the API (2.41 is basically the same, with the addition of a few things to do with Armatures)


If you want to keep everything as one object, you could make a shape key of each displacement . Look for the insert shape key function in the object module .

Thanks everyone for the replies! This is a good start for me. I’ll post my discoveries.

Hi, I am also new to blender and I want to do something similar. I have already written a little python script that calculates meshes of mathematical functions. If someone is interested, I can post the code. Example:

Now I want to add animation, but I don’t know how. My idea is:

  • Create and calculate new mesh at time t
  • Create keyframe
  • t=t+dt
  • Back to 1. (until t >= tmax)How can I do this in blender?

if your just moving vertex locations Mesh is significantly faster then NMesh, since it modifies the vertex location directly. rather then working on a copy and then regenerating the mesh from the copy.

I think moving the vertices is too complicated, because there’s a removeDoubles() call after the mesh creation. So I don’t know which of the original vertices are still there. Maybe I should improve my code, but I will only do it, if there is no easy way to create the animation.

Here’s a link to the script:

And here is a code snippet:

scene = Blender.Scene.GetCurrent() # get current scene
g = Blender.Mesh.New(mname) # create new mesh
go = Blender.Object.New("Mesh",mname) # create new mesh object
vi = [] # declare list for Vertices
fi = [] # declare list for Faces

...(mathematical stuff)...

g.verts.extend(vi) # associate vertices wish mesh 
g.faces.extend(fi) # faces also

g.sel=True  # select object 
print g.remDoubles(epsilon),"double vertices removed"

# find out, how to smooth mesh and put code here 

# How do I delete the vertices and faces of the mesh?

Now the questions are: How can I create a keyframe? Do I only have to call insertShapeKey() ? Then how can I remove the old mesh and insert the newly calculated one for the next keyframe? Or do I have to keep all the meshes and link all of them to the object go?