curframe==curtime ?

Hi, I’m a newbie just now starting to play with BPython.

I’m considering writing a script that does some time-constrained calculations (hence, the result will be dependent upon the current time in an animation).

It appears that

 Get( 'curtime' )

returns identically to

 Get( 'curframe' )

If this is the case, is it correct to calculate time as (eg):

 fps = Scene.GetCurrent().getRenderingContext().framesPerSec()
print 'time is %s sec' % ((Get( 'curtime' ) -1) /fps)

Or is there something I’m missing? A better way to do this? I’m using version 2.36 (Windows build), internal (blender-supplied) python modules only.

Thanks in advance

I suggest download full Python 2.3.4 from
www.python.org, making sure that Blender
knows the Python Lib directory (the “i” Window
Type in Blender), and then using
the time module:

http://docs.python.org/lib/module-time.html

For example:

from time import *

print clock()

Thanks for the response, but I think I misstated what is wanted.

I don’t care what the actual time is. I only want to know what the current frame’s time is. For example, frame 1 is time 0 sec. Frame 25 is (eg) 1 sec and frame 16 is 0.6 sec (all presuming 25 fps).

Am I making some horrible error presuming that ‘curtime’ is always expressed as the current frame number? What is the correct way I should be gathering this information?

well the way you mentionned. is correct. though curtime should give you the same info… it actually send back the frame in float… gonna check about that.

If you’re using ‘curtime’ in a scriptlink, it can return fraction of values when rendering an animation with Fields (half frames) or MBlur (fractions of frames corresponding to each sample).

Otherwise, like Gabio said, it just returns a float value of the current frame.

And you assumption about how to calculate the current time in second is correct.

Martin

Thanks! :smiley: