MEL How-To #45

Back · Previous · Next Maya

How do I toggle playback between "Normal" and "Free" while playback is running? It only seems to take effect when I restart playback at the beginning.

The trick is to stop and restart the playback within the MEL that toggles the Playback Option:

// Is the animation currently playing?
int $isPlaying = `play -q -state`;

// If so, stop.
if ( $isPlaying )
  play -state off;

// Toggle playback mode between "Free" and "Normal"
playbackOptions -ps ( !`playbackOptions -q -ps` );

// If the animation was playing, resume playing with new mode
if ( $isPlaying )
  play -state on;

Related How-To's

Monday, October 23, 2000