4

While I am modeling I like to render a frame to show the progress as I am going along. I would like to program the renderer to save the render as a render output and add an incremental number to the end of it. So I would have a number of renders at the end just like a render sequence for an animation but with the frames I decide to make. The purpose of this is to automate the process of creating a making of.

cdiggins
  • 17,602
  • 7
  • 105
  • 102
Donovan
  • 41
  • 1
  • 2

4 Answers4

2

Here's a loop to increment your filename names at each frame. use the last line's result as your filename.

One problem that you will encounter if you just "add numbers" to your filename is that other applications (including ram player) dont recognize them as a sequence. with the solution below you add it properly, with 0001 - 0002 etc.

change the line ".4i" if you want more 0's in your output.

--Here you'd get the start frame from the UI
    startframe = 0

--Here you'd get the end frame from the UI
    endframe = 10

--temp variable to hold our start frame number.
    tempframe = startframe

--variable to hold our desired filename
    filename = "Filename_"
for i = startframe to endframe do
(
 tempframe +=1
 print "Framenumber is now:"
 print tempframe as string
 print "Filename at this frame would be:"
 format "filename% \n" (formattedPrint tempframe format:".4i" + ".ext") 
)

the result from running this can be seen in the script listener.

IAmNoone
  • 1,011
  • 1
  • 8
  • 25
0

Seems an old question but I think what you need is a MacroScript with a global variable to keep the filename counter and create a keyboard shorcut for that macro so you can render quickly while modeling.

Here is a simple MacroScript i made for the same purpose:

macroScript RenderProgress category:"pX Tools" buttonText:"Render Progress"
(
global rpFileNumber
global rpCameraName
global rpFileName = "c:\\temp\\renderprogress"
if rpFileNumber==undefined then rpFileNumber = 0
if rpCamera==undefinded then rpCamera = $Camera01

local NewFileName = rpFileName + (rpFileNumber as string) + ".jpg"
local bm
if rpCamera == undefined then 
(
    bm = render vfb:false
) else
(
    bm = render camera:rpCamera vfb:false
)
bm.FileName = NewFileName
Save bm 
rpFileNumber += 1
) 

It will render a single frame using "Camera01", if this camera doesn't exist current active viewport is rendered.

To reset the file number counter set rpFileNumber = 0 using MaxScript Listener window Set also path and file name with rpFileName = "c:\myfolder\myfilename"

This script needs a lot of improvement but is currently acceptable.

You can try another more complex solution here: http://forums.cgsociety.org/archive/index.php/t-715599.html

piXelicidio
  • 187
  • 9
0

If you save the files to a new empty folder then each time you save the file you can append an integer to the file name that corresponds to the number of files in the directory.

folder = "c:\\tmp\\renders"
dir = dotNetClass "System.IO.Directory"
files = dir.GetFiles(folder)    
file = folder + "\\render" + files.count as String + ".bmp" 
render outputfile:file
cdiggins
  • 17,602
  • 7
  • 105
  • 102
  • Thanks for the reply, I should mention that I am very new to maxscript and programming. I have done the maxscript tutorials but I can't say I understand all of what I am doing. – Donovan Oct 29 '10 at 08:26
  • I am having trouble getting this to work. I have typed all the info in and changed the folder = to my own work path. under file = folder + i have changed that to be the name of my render and instead of ".bmp" I have chosen ".tga". When I evaluate the script, nothing happens. no errors no renders, absolutely nothing. the full script I have written out is: – Donovan Nov 01 '10 at 11:17
  • folder = "d:\\Work\\Experiment\\RenderScript\\renderoutput" – Donovan Nov 01 '10 at 11:17
  • dir = dotNetClass "System.IO.Directory" – Donovan Nov 01 '10 at 11:18
0

file = render()

then you save the file with what ever name, and where ever you want.

C.J.
  • 15,637
  • 9
  • 61
  • 77