PDA

View Full Version : python frame padding not working (only strips zeros, doesn't add)


cgbeige
08-16-2012, 05:16 PM
I'm trying to pad zeroes on a variable and for some reason this only strips them:

int $maxFrameCountOBJLong = 00940;//this will be $n in a for loop
int $maxFrameCountOBJ = `python ("'%07d' % "+$maxFrameCountOBJLong)`;

xsisupport
08-16-2012, 05:33 PM
You lose the zeroes when you go from a string to an integer.

From the history log, the evaluation results:

int $maxFrameCountOBJLong = 00940;
// Result: 940 //
python ("'%07d' % "+$maxFrameCountOBJLong);
// Result: 0000940 //

mattschwarz
08-16-2012, 05:35 PM
you defined your variables as integers. if you define them as strings it should work:

string $maxFrameCountOBJLong = 00940;
string $maxFrameCountOBJ = `python ("'%07d' % "+$maxFrameCountOBJLong)`;

cgbeige
08-16-2012, 07:15 PM
ya, that works thx

CGTalk Moderation
08-16-2012, 07:15 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.