Maxscript outputfile name with integer variable error

92 Views Asked by At

I'm saving the outputfile name of my renders with an integer variable that has his value added by 1 inside the loop. The problem is that I need the file name to be saved as the following nomenclature: "ImageName-00.jpeg", "ImageName-01.jpeg"... so I can upload it to Turbosquid, but the file is being saved as "ImageName-90001.jpeg", "ImageName-90002.jpeg".

  • Note by Turbosquid:

enter image description here

  • Example as how the files are being saved: enter image description here
  • Line of the code where I make the save:

     _frame = 0
     for current in assetsList do(
         render camera:c fromframe:0 toframe:10 outputfile:(turnPath + "\\" + currentName + "-" + _frame as string + ".jpeg")
         _frame += 1
     )
    
1

There are 1 best solutions below

0
paddy On

One problem is that when you provide a frame range to render, 3ds Max is no longer in single-frame mode and it will append timestamps to your filenames. What happens in your case is the value 9 comes from _frame, and then 3ds Max is appending a 4-digit timestamp for the actual frame number being rendered: 0000, 0001 etc.

Although it's less efficient, an easy way to get around this is to call render once for each frame. That puts the renderer in single-frame mode, and it won't add its own timestamps.

Now, you just need to build the output file name correctly. You can use the formattedPrint function to zero-pad a number.

Putting this together:

for f = 0 to 10 do (
    local fileName = turnPath + @"\" + currentName + "-" + (formattedPrint f format:"02d") + ".jpeg"
    format "Rendering: %\n" fileName
    render camera:c frame:f outputfile:fileName
)