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:
- First, I made a Dialog Box for the user to select what I am calling "Studio" that is a scene with lighting and cameras ready for the render and then open it;
- Second, is another Dialog Box for the user to select the folder where the .max files to render are;
- Thrid, is another Dialog Box for the user to select the folder where he wish to save the renders;
- Then I made a loop where through a list, the program will add the .max file to render as a xref scene and rigth after that get the name of the .max file to use in the saving.
- The next and final loop is to get a render from each camera in the scene and then save but the problem is that the image is not been saved in the folder selected.
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:There's also another way: you can save the bitmap object that the
render()function returns:The directory must exist for any of these methods to work, so you may want to create it before your loop: