Page 1 of 1

delayed / timed / threaded script ?

Posted: September 26th, 2008, 4:55 pm
by berniebernie
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()').

Re: delayed / timed / threaded script ?

Posted: October 6th, 2008, 8:48 am
by lloydalvarez
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)
Description
Schedules the specified JavaScript for delayed execution.
Parameters
Returns
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.
Lloyd

Re: delayed / timed / threaded script ?

Posted: October 10th, 2008, 6:11 am
by phaseIV
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