I've been trying animate a large amount of objects based on location and frame data from an excel sheet. So far I've read through a dozen different threads both here and other forums, but I'm just not able to understand how to do it. My only previous coding experience is only a small amount of html/css, so having a slightly hard time wrapping my head around this.

enter image description here


This is what I use to test on. The goal is to have the script select each object, set its location at a specified frame and keyframe it. So that I can then manually tweak the transition between them if needed.

So far this is the code I have so far, partially copied from here. And i somewhat understand what it does, I think, it at least moves the sphere in the scene.

import bpy
import csv

csvfile = open('FilePath/Sphere_Anim.csv')
readcsv = csv.reader(csvfile, delimiter=',')

for i, row in enumerate (readcsv):
    if i==0: continue
    obname = row[0]
    loc = [float(x) for x in row[1:4]]
    frame = row[4]

    bpy.context.object.location = loc

Would greatly appreciate it if someone could point me in the right direction.


1 Answer 1


Data to blender edits.

  • Get the scene object ob by name. Skip if not present in scene.
  • Add location keyframes at each frame using

    ob.keyframe_insert("location", frame)

    Read the docs:

Edited script.

import bpy
import csv

scene = bpy.context.scene    

csvfile = open('FilePath/Sphere_Anim.csv')
readcsv = csv.reader(csvfile, delimiter=',')

for i, row in enumerate(readcsv):
    if i == 0: 
    obname = row[0]
    # get the object
    ob = scene.objects.get(obname)
    if not ob:
    loc = [float(x) for x in row[1:4]]
    # set location
    ob.location = loc # local
    #ob.matrix_world.translation = loc # global
    frame = int(row[4])
    # insert all location keyframes  
    ob.keyframe_insert("location", frame=frame)


Fast keyframe insertion

  • $\begingroup$ Oh, wow, this seems to work perfectly :) Thanks for the links too, seems I've got a lot to read up on:) $\endgroup$ Mar 10, 2019 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .