View Full Version : progressbar destroys script

06 June 2012, 02:38 PM

this is strange!!!
or maybe I am missing something, but as soon as the user interrupts the progressbar with pressing esc and sources the script again, it only works on the first selected object and not anymore on all objects.
Can anyone tell me what I am missing here?

once you run through the whole progress bar you can source the script again and it will not stop after the first object.

first create some objects to have a mass of objects generating a long progress bar - long enough for us to cancel:

import maya.cmds as mc spheres = []

for i in range (0, 2000):

obj = mc.sphere()

spheres.append (obj[0]) (spheres)

and now the progress bar script:

import maya.cmds as mc selection = (sl=1)

counterMaxLength = len (selection)

gMainProgressBar = maya.mel.eval('$tmp = $gMainProgressBar');

mc.progressBar( gMainProgressBar,




status='"loading user selection ..."',

maxValue=counterMaxLength )

currentCount = 0

for sel in selection:

print sel

currentCount += 1

mc.progressBar(gMainProgressBar, edit=True, step=1)

if mc.progressBar(gMainProgressBar, query=True, isCancelled=True):


mc.progressBar(gMainProgressBar, edit=True, endProgress=True)

any Input very appreciated!!
I'm kinda stuck here.

06 June 2012, 12:40 PM
It doesn't appear that Maya is setting the -isCancelled flag back to false after the user cancels the operation. Unfortunately, that flag can only be queried so you can't explicitly set it yourself.

In brief testing, the only workaround I've found so far is to call a begin and end on the progress bar prior to actually using it. The -isInterruptable flag must be set to true during this operation. After calling endProgress, the -isCancelled flag is set back to false.

mc.progressBar(gMainProgressBar, edit=True, isInterruptable=True, beginProgress=True)
mc.progressBar(gMainProgressBar, edit=True, endProgress=True)

06 June 2012, 01:14 PM
ok, I will try.
thank you!

CGTalk Moderation
06 June 2012, 01:14 PM
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.