PDA

View Full Version : is there a way to create a timer?


deebster
10-26-2006, 09: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?

Mikademius
10-26-2006, 03:12 PM
Hehe, funny and interesting :) I don't have any spesific ideas though... But it sounds like a funny challenge ;)

Adam
10-26-2006, 04:36 PM
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`;

string $TimeA[];

tokenize $Time ":" $TimeA;

int $Hour = $TimeA[0];

if ($Hour > 12)

{

$TimeA[0] = $Hour -12;

}

$Time = $TimeA[0] + ":" + $TimeA[1] + ":" + $TimeA[2];

print $Time;

return $Time;

}

if (`headsUpDisplay -ex TimeHeadsUp`)

{

headsUpDisplay -rem TimeHeadsUp;

}

else

{

headsUpDisplay -section 9

-block 4

-blockSize "medium"

-label "Time"

-labelFontSize "large"

-command "TimeProc()"

-ev "idle"

TimeHeadsUp;

}






let me know if you have any questions

BlackHwk4
10-28-2006, 12: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;
else
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);
}

CGTalk Moderation
10-28-2006, 12: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.