delayed / timed / threaded script ?

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Posts: 33
Joined: February 7th, 2005, 7:32 am

hello guys

I've written a quick maya mel file that outputs the coordinates of the camera every 1 second or so to a text file, and I'm trying to fetch the data of the text file in AE. I can read it in no problem, but my question is, can I do it with a kind of 'threading'.

Can I have a script that checks the contents of the file every x seconds and updates the AE camera coordinates as needed ?

I'm clueless as to how I can implement some kind of 'wait' function so my script doesn't just endlessly loop (kind of like 'setTimeout()').
Boom boom boom.
User avatar
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY

You can try using a while loop like this:

Code: Select all

while(i < 1000000) i++;
adjust the value as necessary.

You can also experiment with scheduleTask (from p29 in the CS3 scripting guide):
Application scheduleTask() method
app.scheduleTask(stringToExecute, delay, repeat)
Schedules the specified JavaScript for delayed execution.
Integer, a unique identifier for this task, which can be used to cancel it with app.cancelTask().
stringToExecute A string containing JavaScript to be executed.
delay A number of milliseconds to wait before executing the JavaScript. A floating-point value.
repeat When true, execute the script repeatedly, with the specified delay between each execution. When false
the script is executed only once.
Posts: 1
Joined: September 10th, 2008, 2:29 pm

You could use the sleep() function which is part of the Dollar ($) Object debugging facility.
See the Javascript Tools Guide for details.

Works for me when used as

Code: Select all

$.sleep(5000); // wait 5 seconds
Post Reply