MAXScript / pymxs expose several functions for working with animations in 3ds Max.
The animation range is held in the animationRange global, which holds an Interval value. Intervals represent a range of time. So for example to get the frame range and change it:
>>> pymxs.runtime.animationRange
<Interval<(interval 0f 100f)>>
>>> pymxs.runtime.animationRange = pymxs.runtime.interval(0,200)
Animation keys can be set using the pymxs version of the MAXScript at time
context expression, pymxs.attime()
. Note that pymxs.animate()
must be set to True first.
rt = pymxs.runtime
t = rt.teapot()
with pymxs.animate(True):
with pymxs.attime(0):
t.pos = rt.point3(0,0,0)
with pymxs.attime(100):
t.pos = rt.point3(0,10,100)
pymxs
provide two functions for controlling animation: playAnimation()
and stopAnimation()
. You can query whether animation is playing with isAnimPlaying(). For example:
>>> pymxs.runtime.playAnimation(immediateReturn=True)
>>> pymxs.runtime.isAnimPlaying()
True
>>> pymxs.runtime.stopAnimation()
True
To set the playback speed, use the timeConfiguration.playbackSpeed setting. For example, to set the playback speed to 2x:
pymxs.runtime.timeConfiguration.playbackSpeed = 4
All of the settings on the Time Configuration dialog are exposed to pymxs/MAXScript. See the "Time Configuration Dialog" topic in the MAXScript Help for more information.