View Full Version : is there a way to create a timer?
10-26-2006, 10:07 AM
hey guys. I just wanted to create a fun little script that let's me know if I've been on Maya too long. Does anyone know how to do that with MEL scripts?
10-26-2006, 04:12 PM
Hehe, funny and interesting :) I don't have any spesific ideas though... But it sounds like a funny challenge ;)
yeah it is actually pretty easy to do. You can get the internal computer time. So simply use that when you start to record when you started maya and then check on my idele state (through a scriptjob) if you have met or exceded that (time + x hours). I am attaching a script I wrote to create a little clock in your heads up display. It uses the same principles that you would need plus some extra crap.
I have it set to a shelf button if you press it it truns it on and if you press it again it turns it off.
global proc string TimeProc()
string $Time = `about -ct`;
tokenize $Time ":" $TimeA;
int $Hour = $TimeA;
if ($Hour > 12)
$TimeA = $Hour -12;
$Time = $TimeA + ":" + $TimeA + ":" + $TimeA;
if (`headsUpDisplay -ex TimeHeadsUp`)
headsUpDisplay -rem TimeHeadsUp;
headsUpDisplay -section 9
let me know if you have any questions
10-28-2006, 01:49 PM
I made something like that too, but using the event idle makes the CPU usage jump to 100% so I never used it. It didn't seem to slow down Maya though. It should give an idea on what to do.
global proc HUDstopWatch()
global float $startTime;
$startTime = `timerX`;
if (`headsUpDisplay -ex HUDelapsedTime`)
headsUpDisplay -rem HUDelapsedTime;
headsUpDisplay -s 9 -b 4 -l "Time:" -ev "idle" -c "getTime($startTime)" HUDelapsedTime;
global proc string getTime(float $startTime)
float $curTime = `timerX -st $startTime`;
int $minutes = $curTime / 60;
int $seconds = $curTime % 60;
int $hours = $minutes / 60;
$minutes %= 60;
return ($hours + ":" + $minutes + "." + $seconds);
10-28-2006, 01:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.