The Animation Replicator with Offset - Part 2

Finally, I managed to complete the second part of the ARewO tutorial. It can now distribute objects along a path and include armatures.

If you haven't watched the first part, I strongly recommend you to do so.

So here is the script:

  1. span style="color: #483d8b;">'Placer'"linked"'SELECTED_OBJECTS''DESELECT'#verschieben
  2. "done")

And here the explanation:

  1. span style="color: #483d8b;">'Placer']
These are the important variables. Arm is the armature you want to include, notice that it has to be the active object in your bunch. Kinder are all selected objects and placer is an object that flies anywhere it wants, but it needs to exist with the name "Placer".

  1. span style="color: #483d8b;">"linked"
This calls a for loop that will execute as many times as you specified with the "loops" variable.
We want a linked copy of our object, in case we want to change something later and also linked objects render faster.
  1. span style="color: #483d8b;">'SELECTED_OBJECTS'
But we cannot have the animation linked, because we want to offset it in time, and if we wouldn't make it a single user, our offset would go into all our armatures, thus synchronizing them.

Now this is a tricky one, try parenting an object to an empty, then remember its location displayed in the "n" menu. then move only the empty, you'll see, even though your object has moved in space, its location is the same. Same for pathes, so we need to find the absolute location of our placer object, in order to be able to make our armature copy its position. If you type in C.active_object.matrix_world in the console, you'll see that it's a 2 dimensional array, thus requiring 2 indices, I picked out the right ones for you, they result in the world x, y and z location.

  1. animData = arm.animation_data
  2. action = animData.action
  3. fcurves = action.fcurves
Those are just variables that make it a little easier for someone else to follow the code.
Kinder is german for children. I don't like to use reserved terms for variables like "children". But the code is supposed to select all children, so I chose the German word for it, feel free to change it.
Oh, right, the actual explanation: it will reselect all objects that were selected when we pressed "run script".

  1. span style="color: #808080; font-style: italic;">#verschieben
This part looks through all f-curves and then trough all keyframes in each f-curve. It then moves them in x (time) by the offset we specified.

  1. span style="color: #483d8b;">"done")
This indicates that the script worked with surgical precision.

Download the finished .blend here!