View Full Version : incremental filenames

11 November 2010, 05:12 PM
So, I've got a script that outputs one file per frame (mesh data).
then problem I've got is the following:

I want the filename to be like this:


But I've got trouble making it work like that.
All i have now is hardcoded 0's, so when it comes to 10 it looks like this:
instead of:
This causes trouble for me after rendering, because 3dsmax
does not see the files as a sequence.

How can one easily add this type of counting to file output in maxscript?

thanks in advance.

11 November 2010, 08:18 PM
You can pass your number to this function. It'll return a string with the right amount of zeros that'll go before your number:

fn getZeros zeroCount val =
zeroStr = ""
valStr = val as string
if (valStr.count < zeroCount) do
for x in 1 to (zeroCount - valStr.count) do zeroStr += "0"
zeroStr -- return value

Since you want it to be at least 4 numbers you can use it like this:

getZeros 4 2
>> "000"

getZeros 4 22
>> "00"

getZeros 4 222
>> "0"

getZeros 4 2222
>> ""

11 November 2010, 08:21 PM
Why not just use formattedPrint?

result = ""
nr = 54
formattedPrint nr format:".4i" to:result
-- "0054"

formattedPrint nr format:".3i" to:result
-- "054"



11 November 2010, 08:33 PM
thanks to both of you, this seems to be what I need!

Thanks for the quick reply.

CGTalk Moderation
11 November 2010, 08:33 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.