开发者

How can I save single renders incrementally with max script

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 t开发者_Python百科he frames I decide to make. The purpose of this is to automate the process of creating a making of.


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.


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


file = render()

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜