Frame Per Second Check

Hi
I am writing a script to animate some gears and want to generate a continously rotating driver. There is no problem with generating this but I would like to set the frequency to an exact speed of rotation which is independant of Maya's framerate.
i.e. when generating the cycle a set a value of rotaation then adjsut time and set a keyfrmae, using a loop I generate the cycle and set it to post infinity and works OK.
But what I want is to set the time based on actual time not frames and to do this I want to query Maya's settings or preferences to find the user's frame rate and use this as a unit of time to index for each set rotation.
Maya's help files say to use the playbackOptions in query mode but this does not give me an answer as it keeps coming back 0.
Example of code from script.
// float $FpS = 60; // is commented out at the moment

float $FpS = playbackOptions -q -framesPerSecond;
print ("$FpS is " + $FpS + "\n");
result printed is $FpS is 0
rest of loop is below;
for ($k=0; $k<9; $k++)
{
$r = ($k * -45);
setAttr ($Drivers[0] + ".rotateX") $r;
setKeyframe -attribute "rotateX" -t ($k * $FpS) $Drivers[0];
float $Time = ($k * $FpS);
// print ("Current Time is " + $Time + " and ");
// print ( "Rotation is " + getAttr ($Drivers[0] + ".rotateX") + "..

hi, using [b]playbackOptions -q -framesPerSecond[/b] will only tell you what the FPS is during playback, so you will always get 0 if you're not playing your anim. If you simply want to know the FPS set in the preferences, this is a "current unit" value, and can be queried using the currentUnit command:

currentUnit -q -time;

however, this always returns a string and you'll have to determine the actual FPS based on this, just as Alias themselves have to do in the internal script: scripts\startup\createPrefWndUI.mel

it's a nasty system but I think that's the only way to get the current FPS (I don't deal with time or animation very much though)

:nathaN

Hi

Thanks for the reply. That's exactly what I was looking for but as you say it makes for a very "messy" result looking at how Alias have handled will probably the way I have to go.

OH Well guess more scripting needed.

Thanks again

(Edit)

OOps! found an easier way as Alias's has done it with a procedure called

currentTimeUnitToFPS in same directory and this gives the following

float $FpS = `currentTimeUnitToFPS`;
print ("$FpS is " + $FpS + "\n");

result $FpS is 24