PDA

View Full Version : Help me with time functions


ducvemt
08-06-2008, 01:39 AM
How to check the current time?
I get the exam. I create a cube. After that i using mel script to driving it. I want the slide run to frame 24 , the cube is jumping 10 unit .
You can teach me using time function to make it? thank!

misterdi
08-06-2008, 05:33 AM
How to check the current time?
I get the exam. I create a cube. After that i using mel script to driving it. I want the slide run to frame 24 , the cube is jumping 10 unit .
You can teach me using time function to make it? thank!

currentTime ????

To query current time do
var curtime = `currentTime -q`;

To move to other time (i.e frame 24) do
currentTime -e 24;

Cheers,

ducvemt
08-06-2008, 06:45 AM
can you show me some exams about controlling object with time functions?

misterdi
08-06-2008, 07:56 AM
This is a really simple example on expression

//Preparing test object and attributes
string $Objs[] = `polyCube -sx 1 -sy 1 -sz 1 -n test_Cube`;
string $Obj = $Objs[0];
string $attrs = $Obj + ".translateX";

//Preparing expression string
string $expr = "";
$expr += "float $fc = `currentTime -q`;\r\n";
$expr += $attrs;
$expr += " = $fc;";

//Setting up expression
expression -s $expr -o $Obj -ae 1 -n "test_expression";

The script above will do:
1. Create a polyCube object name "test_Cube"
2. Adding an expression on translateX attribute.
3. The expression itself look like this
float $fc = `currentTime -q`;
test_Cube.translateX = $fc;
What the expression said:
1. Get the current time (frame)
2. Use this value for translateX attribute.

Phlok
08-06-2008, 03:46 PM
I am looking for something similar and I just cannot find the apropriate command:

I wrote something like this:


while( currentTime -query < 300)
{
if ($actScale[0] == $scaleMax)
{
print "IF Kontrollschleife erreicht \n";
setAttr $placeholder.scaleX $scaleStart;
}
}



...but sadly this results into an error:


// Error: Invalid use of Maya object "currentTime". //
// Error: while( currentTime -query < 300)
//
// Error: Invalid use of Maya object "query". //



All I need is some kind of loop, just like "Do this until frame XY is reached".

misterdi
08-06-2008, 04:14 PM
currentTime is a command,

use `currentTime -query` in your loop

while( `currentTime -query` < 300)
But are you sure you want to use a while loop here?.
Be careful with your flow, otherwise you may have infinite loops.

ducvemt
08-07-2008, 09:33 AM
thank! i got it ! but i trying higher level!!

CGTalk Moderation
08-07-2008, 09:33 AM
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.