I am making a script to automate the process of render multiple .max files. I almost finished what I pretend to achive, the only problem is that I don't know how to save the render image by maxscript. I tried several ways I foud on the internet but none of them works.
studioFile = getOpenFileName caption: "Select the Studio"
loadMaxFile studioFile
folderPath = getSavePath caption: "Select the Folder with the Assets to Render"
maxPath = folderPath + "\*.max"
maxFiles = getFiles maxPath
renderPath = getSavePath caption: "Select the Render Folder"
for current in maxFiles do(
xrefs.addNewXRefFile current
currentName = getFilenameFile current
print currentName
for c in cameras where classof c != Targetobject do(
render camera:c output: ("E:\\MUVA\\Renders\\" + currentName + "_" + c.name + "_" + ".jpeg")
)
xrefs.deleteAllXRefs()
)
This is how my code is for now and explaining it:
I really don't know more what to do. So, I would be very grateful if somebody could help me with this.
PS.: The selected folder to save the renders is not been used in the output of the render by now because I was testing putting all the path to the folder.
As per MAXScript reference, the parameter for filename is outputfile:
. In your case the line would be:
render camera:c outputfile:("E:\\MUVA\\Renders\\" + currentName + "_" + c.name + "_" + ".jpeg")
There's also another way: you can save the bitmap object that the render()
function returns:
bm = render camera:c
bm.filename = "E:\\MUVA\\Renders\\" + currentName + "_" + c.name + "_" + ".jpeg"
save bm
The directory must exist for any of these methods to work, so you may want to create it before your loop:
makeDir "E:\\MUVA\\Renders" all:true