Last active
February 4, 2022 20:19
-
-
Save AndrewHazelden/b7c88242782b7acfcd34 to your computer and use it in GitHub Desktop.
A MEL script for updating a progress bar as a task is running. If the escape key is pressed the task stops and the progress bar is hidden.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int $startFrame = `getAttr "defaultRenderGlobals.startFrame"`; | |
int $endFrame = `getAttr "defaultRenderGlobals.endFrame"`; | |
// The $frameStep variable is used to implement frame skipping using the "By Frame" render settings attribute. | |
int $frameStep = `getAttr "defaultRenderGlobals.byFrameStep"`; | |
string $progressText = ""; | |
if($startFrame != $endFrame){ | |
// Show a rendering progress bar | |
progressWindow | |
-title "Batch Rendering" | |
-status "Rendering" | |
-minValue $startFrame | |
-maxValue $endFrame | |
-isInterruptable true; | |
} | |
int $i=0; | |
for($i=$startFrame;$i<=$endFrame;$i+=$frameStep){ | |
// Check if the dialog has been cancelled | |
if ( `progressWindow -query -isCancelled` ) { | |
break; | |
} | |
$progressText = ("Frame: " + $i + " of " + $endFrame); | |
// Update the progress bar status | |
progressWindow -edit | |
-progress $i | |
-status $progressText; | |
pause -sec 1; | |
} | |
// Hide the progress window | |
progressWindow -endProgress; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment