Using an expression, equation, or connection to automatically animate an object

Hey all,

First post. I’m pretty stoked to be learning Blender and checking out this forum. I’m impressed with how robust the software has become over the last few years and how the community of users has grown. I work in a Maya shop so that’s my native tongue. I’m trying to adapt a lot of my techniques to the Blender workflow. I’m current working on my first project.

I did some research and found very little on this topic so maybe somebody here can shed some light:

I’m trying to automatically animate an object. Is there a way in blender that I can attach an equation (in this case it may be some Python scripting) to the transform attribute of an object (location, rotation, scale)? The equation would update every frame to produce a new value. In Maya I’m used to attaching a MEL expression to an object that’s cued to the frame number. A good example would be having a gear rotate on its own by just using the frame number to calculate the rotation. That way, I don’t need to mess with keyframes. When I put in a different size gear and want the teeth to mesh, I just paste the same equation in there and change a constant to reflect the difference in size. Then the gears sync up. It’s a useful technique but I was wondering if somebody knew how this could be done in Blender or point me in the direction of a good tutorial to work through.

An alternative way for me to have my object animate on its own is to set two keyframes and then tell it to loop or continue after the last keyframe. I haven’t done much research to see if this can be done but maybe somebody here would have a quick answer on how to do that.

Thanks for the help!

Good place to start your research is with PyDrivers:

http://wiki.blender.org/index.php/Dev:Source/Blender/2.42/PyDrivers

PyDrivers are the closest equivalent to Maya’s MEL expressions in terms of driving discrete transform channels (IPO channels in Blender jargon). You can also write entire scripts and link those to your Scene objects using Scriptlinks – that’s a bit more complicated but opens up more options than driving IPO channels.

BTW, welcome in. I also came to Blender from a mostly Maya background and though the learning curve was a bit twisty sometimes, in the end I’ve found Blender just as capable for the kind of animations I do.

Hi,

I’ll leave the Python question to those with more experience, but you can set the interpolation and extend mode of curves in the IPO editor. It sounds like setting Curve>Extend Mode to Extrapolation is the setting you’re thinking of to ensure the animation keeps going beyond the keyframes.

Chipmasque,

Appears to be exactly what I’m looking for! The help is much appreciated.

I agree, the more I learn about Blender, the more capable I’m finding it to be. Some of the pieces users produce on this site are mind blowing! I think half of the battle in making the jump is translating the jargon (in this instance expression = PyDriver). Thanks for assuring me that it can be done though…

rawpigeon,

Thanks much for the cool tip about extend mode. That will definitely come in handy for me.