Last active
December 9, 2015 11:39
-
-
Save AndrewHazelden/a1ab6dcfc6d87d5b0c7b to your computer and use it in GitHub Desktop.
A MEL script for generating a frame padded number. In this case the source value that is frame padded with leading zeros is the start frame value from the Maya Render Settings window
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
// Add zero digit padding to an int value | |
global proc string pvr_zeroPadding(int $num, int $padding){ | |
// Tip from the blog post: http://ldunham.blogspot.ca/2012/01/melpython-adding-number-padding.html | |
int $lengthNum=size(string($num)); | |
string $padString; | |
if($lengthNum<$padding){ | |
for($i=0;$i<($padding-$lengthNum);$i++){ | |
$padString=$padString+"0"; | |
} | |
} | |
return $padString+string($num); | |
} | |
// Get the current frame padding level from the Maya Render Settings window | |
int $padding = `getAttr "defaultRenderGlobals.extensionPadding" `; | |
// Get the start frame from the Maya Render Settings window | |
int $startFrame = `getAttr "defaultRenderGlobals.startFrame"`; | |
// Generate a frame padded number as a string | |
string $paddedFrame = pvr_zeroPadding($startFrame, $padding); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment