如何使用 max 脚本增量保存单个渲染

发布于 2024-09-29 18:12:12 字数 119 浏览 9 评论 0原文

当我建模时,我喜欢渲染一个框架来显示我的进展。我想对渲染器进行编程,将渲染保存为渲染输出,并在其末尾添加一个增量数字。因此,我最终会进行许多渲染,就像动画的渲染序列一样,但使用我决定制作的帧。这样做的目的是使创建过程自动化。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

看轻我的陪伴 2024-10-06 18:12:12

这是一个在每一帧增加文件名的循环。
使用最后一行的结果作为文件名。

如果您只是将数字“添加”到您的计算机中,您会遇到一个问题
文件名是其他应用程序(包括内存播放器)无法将它们识别为序列。
使用下面的解决方案,您可以正确添加它,例如 0001 - 0002 等。

如果您希望输出中包含更多 0,请更改行“.4i”。

--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") 
)

运行的结果可以在脚本监听器中看到。

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.

绾颜 2024-10-06 18:12:12

如果将文件保存到新的空文件夹中,则每次保存文件时,您可以在文件名后附加一个与目录中文件数相对应的整数。

folder = "c:\\tmp\\renders"
dir = dotNetClass "System.IO.Directory"
files = dir.GetFiles(folder)    
file = folder + "\\render" + files.count as String + ".bmp" 
render outputfile:file

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
我偏爱纯白色 2024-10-06 18:12:12

file = render()

然后你可以用任何名称保存文件,并保存在你想要的地方。

file = render()

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

殊姿 2024-10-06 18:12:12

似乎是一个老问题,但我认为您需要的是一个带有全局变量的 MacroScript,用于保留文件名计数器并为该宏创建键盘快捷键,以便您可以在建模时快速渲染。

这是我出于相同目的制作的一个简单的 MacroScript:

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
) 

它将使用“Camera01”渲染单个帧,如果该相机不存在,则渲染当前活动视口。

要重置文件编号计数器,请使用 MaxScript Listener 窗口设置 rpFileNumber = 0
还可以使用 rpFileName = "c:\myfolder\myfilename" 设置路径和文件名。

此脚本需要大量改进,但目前可以接受。

您可以在这里尝试另一个更复杂的解决方案:
http://forums.cgsociety.org/archive/index.php/t -715599.html

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文