When keyframing the motion of an object, it sometimes becomes clear that the motion follows a pattern, so there must be a better way to animate the object. This is especially true if the motion is simple but repetitive. Out of Range functions in 3ds Max can help, but they carry on until the end of the scene once applied, and this is often not flexible enough. In this situation, a neat bit of MAXScript may be just the answer.
One type of motion that is all around us, and therefore frequently animated, is oscillation: an object moving backwards and forwards. Most oscillating objects follow a simple rule called the sine wave, which has the distinctive mathematical property of having its speed and acceleration also defined by sine waves. This makes the motion of the object defined by the sine wave appear smooth and natural. Just about every programming or scripting language has the ability to apply the mathematical sine function, so it is relatively easy to write some script to animate objects oscillating. More importantly, once the script is written, it can be used over and over on different and multiple objects.