Changing Curr Frame During Playback?

Greetings!

I was wondering if there is any way to change the current frame during playback? Let's say that every time we hit frame 30, I want to move playback back to frame 10. I've tried using a scriptJob, but I can't get the -timeChange parameter to work well for me, and the "timeChanged" event only fires when you click and change the time via the timeline, not while you are playing the scene back.

I was able to create a script node like the following:

createNode script -n "myScript";
setAttr ".b" -type "string" "if (currentTime -q == 30) {currentTime -e 10;};";
setAttr ".st" 7;

But the problem is that although at frame 30 it goes to frame 10, the very next frame played is frame 31, not frame 11. I've also tried using "play -st false" in the script node to turn off playing and then turn it back on after the switch, but that didn't work. Just calling "play -st false" from the script node will lock up Maya and requrie the process to be killed.

So, is there any way to change what frame you are playing back from during playback?

The reason I'm trying to solve this problem is I'm working on a script that plays a frame range from one camera, and then play another frame range from a second camera. The frame range for camera 1 and camera 2 might have gaps between them, or might overlap, so I'm trying to control the active/displayed camera and what frame range is being played back on the fly.

Thanks for any help.

Cheers,
Michael Duffy

QUOTE(MDuffy @ 04/10/07, 10:17 AM) [snapback]263853[/snapback]
I was wondering if there is any way to change the current frame during playback? Let's say that every time we hit frame 30, I want to move playback back to frame 10. [...]

CODE
expression -s "if (30 == currentTime -q) currentTime 0";

QUOTE(MiloDC @ 04/10/07, 10:30 AM) [snapback]263854[/snapback]
CODE
expression -s "if (30 == currentTime -q) currentTime 0";

Unfortunately that has the same effect as the script node I posted earlier. If you run that line of code, make sure you have at least 40 frames visible in the timeline, switch Maya to playback at about half rate, and hit play, then the time plays linearly except at frame 30 where it would display frame 0 instead. After frame 0, playback continues from frame 31, not frame 1.

My fear is that the playback control loops over an internal variable and sets the currentTime from that variable, rather than checking currentTime each frame. To get around this I may have to code an external script/application that sends "currentTime" commands over a command port to Maya 24 or 30 times a second. But that isn't very cross platform, and I was hoping to keep everything in MEL.

I'm in Maya 7.0, and I tried the approaches under both Windows and Linux with the same results in both.

Cheers,
Michael Duffy

Yes maya RUNS time forward in values cached, however. Also script jobs are on PURPOSE suspended during playback.

Anyway theres 2 simple solutions for this.

1) create a time node key it to a linear up curve and loop a section of it. Then connect this time to all your scenes time controlled things. This effectively makes maya run animatoion forward but it will loop in teh manner yyou want (you can even pinpong a asection or slow in or so on)
2) same as above but connect this to a expression that sets current time

The only thing 2 does that 1 doesent do is make sure you undertsand wht the real frame is in the timeline.

3) didnt test (no maya at hand) but it is possible thet you can set time1 trough the expression and maya owuld count form that,