Hi Marcus,

Thank you for your reply!

Actually I used the similar method to write a function yesterday, and I 
would like to share the codes here. 

def getFPS(startFrame, totalFrames):     
cmds.currentTime(startFrame)
startTime = time.time()
for i in range(startFrame,startFrame+totalFrames):
    cmds.currentTime(i)
fps = totalFrames/(time.time()-startTime)
return fps 

I consider this is the workaround solution, and I just wondering whether 
there were any API Class could do this? 

Thanks,
Parker


On Saturday, November 15, 2014 7:44:28 PM UTC+8, Marcus Ottosson wrote:
>
> As you haven’t gotten a reply, I’ll share what I was thinking at first.
>
> If you count the time between the frames, you can calculate your own fps.
>
> import time
>
> time_before = time.time()
> # your code here
> time.sleep(0.1)  # Pretend it takes a tenth of a second per frame
>
> time_after = time.time()
> time_delta = time_after - time_before
> fps = 1.0 / time_delta
> print "%f fps" % fps
>
> Which prints, around:
>
> 9.30343 fps
>
> ​
>
> On 13 November 2014 20:04, Chi Ngai Lai <[email protected] <javascript:>
> > wrote:
>
>> Hi All,
>>
>> I'm going  to write a script, which I want a realtime FPS value during 
>> the scene playback. 
>>
>> I've tried the following codes, which were not worked for me. 
>>
>> # specify how many times for playing
>> cmds.playbackOptions(loop='once')
>> # scrub the time cursor to frame 1
>> cmds.currentTime(1)
>> # begin to play
>> cmds.play()
>>
>> # make sure the scene is playing, then query for the realtime fps value
>> if cmds.play(q=True, st=True):
>>     print cmds.playbackOptions(fps=True)
>>
>> Result: it only print 0.0 at the beging, then it stops printing fps 
>> values, and the scene was continue playing.
>>
>> I've to manually keep executing those 2 lines of "if" codes, then it 
>> could keep printing the realtime fps value for me. 
>>
>> But I want it automatically keep printing the fps values for me during 
>> the playback. 
>>
>> Any thoughts? Much appreciate in advance. :)
>>
>> Cheers,
>> Parker
>>
>>
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/python_inside_maya/86e30ad5-e448-42dd-b577-ef5a9b6925a0%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/python_inside_maya/86e30ad5-e448-42dd-b577-ef5a9b6925a0%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> *Marcus Ottosson*
> [email protected] <javascript:>
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/6995560b-3659-4cf7-8029-df4f4935ec17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to