Thursday, August 8, 2013

ProgressBar Bug??

I've been building a simple context manager to wrap Maya's progressBar and come across a nice little Maya bug, or so it seems.

Run the following with the script editor open. Now press escape once, it aborts right, run it again, the sequence still runs and prints out the counter. Now next time you hit escape hit it a few times, as most people do when escaping a large task. Next time you run the code, it'll only do a single test before aborting.... it's like the progress bar is holding the escape key in a cache, so hit it once and next time it's clear to run, hit it twice and it's almost like it's storing it up...

import maya.cmds as cmds
import maya.mel as mel
gMainProgressBar = mel.eval('$tmp = $gMainProgressBar')
cmds.progressBar( gMainProgressBar,
    status='Example Calculation ...',
    maxValue=5000 )
for i in range(5000) :
    print i
    if cmds.progressBar(gMainProgressBar, query=True, isCancelled=True ) :
    cmds.progressBar(gMainProgressBar, edit=True, step=1)
cmds.progressBar(gMainProgressBar, edit=True, endProgress=True)

Can somebody else confirm that I'm not going mad!!

No comments:

Post a Comment