0
$\begingroup$

Mesh vertex animation

My prerequisites: Little to no experience with blender, advanced experience in python

Starting Point: Mesh M with n vertices and m faces as .obj file.

Next step : Change coordinates of the n vertices incrementally.

What I have : Python script that calculates the new vertex coordinates for X timesteps

What I need : How to apply the list of new vertex coordinates to the mesh in blender with the related timesteps (=frames). (Python API of blender?) Is there something like:

for timestep in range(0,len(timesteps)):
    newCoordinates = calculateCoordinates(mesh.vertices, timestep)
    mesh.co = newCoordinates
    mesh.Update()
    
    # --> add keyframe to animation

What I tried:

  • PlugIn Animall seems to have that functionality, however, I was not able to get that to work for my problem
  • Keyframe animation is an older post from 2015. The aim appears to be similar, however none of the code snippets is working nor is leading to the desired results
$\endgroup$
6
  • 1
    $\begingroup$ Does this answer your question? How to keyframe mesh vertices in Python $\endgroup$
    – batFINGER
    Aug 18 '20 at 8:54
  • $\begingroup$ Have made the necessary (and very minor) edits to 2 of 3 answers to update them to 2.8. The other handler technique is similar to blender.stackexchange.com/questions/187361/… $\endgroup$
    – batFINGER
    Aug 18 '20 at 9:23
  • $\begingroup$ blender.stackexchange.com/questions/74063/… $\endgroup$
    – batFINGER
    Aug 18 '20 at 9:35
  • $\begingroup$ Okay thanks a lot! Will check that tonight $\endgroup$
    – BennyS
    Aug 18 '20 at 9:37
  • $\begingroup$ Thank you very much batfinger, it works now! Just one little additional question : Is it possible to "vectorize" the "for v in mesh.vertices"- loop in your first suggested answer? I do have N - matrices containing the vertex coordinates for N frames. I would just have to rewrite the vertice coordinates for each frame instead of for each vertex for each frame. Is it possible to improve its performance here? $\endgroup$
    – BennyS
    Aug 19 '20 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.