I am trying to follow Blender sushi tutorial about animation with python, The video link is here https://www.youtube.com/watch?v=EWX0e1tyV5w

The text version here http://blendersushi.blogspot.fi/2013/05/python-nla-non-linear-animation-with.html

Every times I run the script, it fails on the line

if NEWTRACK in rig.animation_data.nla_tracks:
  • $\begingroup$ Can you post the error message printed to the console window blender.org/manual/interface/window_system/console_window.html $\endgroup$
    – batFINGER
    Mar 20, 2016 at 17:25
  • $\begingroup$ The error : AttributeError: 'NoneType' object has no attribute 'nla_tracks' $\endgroup$ Mar 20, 2016 at 17:58
  • $\begingroup$ ie the "rig" material has no animation data. $\endgroup$
    – batFINGER
    Mar 20, 2016 at 18:03
  • $\begingroup$ The thing is i don't have a rig in the file, Please watch the video is just about 5 min $\endgroup$ Mar 20, 2016 at 18:08
  • $\begingroup$ I did some digging this question could more like does Blender python still uses rig.animation_data.nla_tracks with object? $\endgroup$ Mar 20, 2016 at 21:07

1 Answer 1


There are a couple of scripts in one rig = bpy.context.active_object in the other rig = bpy.context.active_object.data.materials[0] I'm assuming you are on the first as the second (materials one) creates the animation_data.

The objects are taken from the context.selected_objects collection, by name, then sorted, then iterated and made active.

However if you have an object selected that doesn't have any animation_data, ie has no action with keyframes nor a driver, then the script will fail because obj.animation_data is None and as the error says

AttributeError: 'NoneType' object has no attribute 'nla_tracks'

One fix would be to replace

objs = bpy.context.selected_objects


objs = [o for o in bpy.context.selected_object if o.animation_data]

or go straight to names

names = [o.name for o in bpy.context.selected_objects
            if o.animation_data]

to make sure each object, from selected_objects collection, has animation data.

  • 1
    $\begingroup$ Thanks for the answer, yes it does solve the first problem and then i got an other one. But i don't know should i post an other question or should i just ask for the working script if you did make it work? For the problem i get an error. RuntimeError: Error: unable to add strip (the track does not have any space to accommodate this new strip) Note that i m beginner in python or should i say bpy $\endgroup$ Mar 22, 2016 at 18:13

You must log in to answer this question.

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