Theres actually mechnanism in mel for inetruptions which you should use. However just like here scripts are not genreally inetruptable you need to make them interuptable, So modifying the example above slightly would result in:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
global string $gMainProgressBar; // This is defined on maya startup
progressBar -edit
-beginProgress
-isInterruptable true
-status "Example Calculation ..."
-maxValue 10000000
$gMainProgressBar;
for($i=0; $i < 10000000; $i++) {
if(`progressBar -query -isCancelled $gMainProgressBar`)
break;
print $i;
progressBar -edit
-step 1 $gMainProgressBar;
}
progressBar -edit
-endProgress
$gMainProgressBar
now hitting escape will terminate. So any scripter who actually makes something heavy, need to do this themselves. If not then its the scripters fault. Thing is tough you shouldnt really chek for intterupt and update every loop as it just slows you down
f we run an infinet loop in MEL, how to terminate it?
When it goes of it goes of and your maya is dead forever and theres NOTHING you can do about it. Uless your code was designed to be interuptable it will not be. Theres no generic break in maya.