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.
- 00:00 - 02:20 Overview and examples
- 02:20 - 05:40 Comparison to the previous script
- 05:40 - 08:40 Rewriting the armature function
- 08:40 - 11:40 How to create a path to distribute the objects
- 11:40 - 17:30 Placing the objects along the path
- 20:10 - 24:40 General tweaking
So here is the script:
And here the explanation:
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.
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 sychronizing them. Now this is a tricky one, try parenting an object to an empty, then remember it's location displayed in the "n" menu. then move only the empty, you'll see, even though your object has moved in space, it's 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 it's 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. 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".
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. This indicates that the script worked with surgical precision.