Thursday 16 March 2023

padding numbers in maya - mel

 python - Number/Version Paddings in Maya - Stack Overflow
don't know why I've never really had to do this before heh. Watch out for the backticks. The python bit really wants the ' and not the `, but then the mel bit really wants the `. sigh.
Also hilarious that you have to use a python function for this.

$padding = 3;
$num = 5;
string $pad = `python ("'%0"+$padding+"d' % "+$num)`;
// Results is: 005