[Closed] Batch Operation: Change Material and Render
Hi Everyone and thank you for reading.
I have a lot of simple renders to do, and to do them manually is making me waste a lot of time.
Any help to automate the process will be really really appreciate.
Into a scene there is a material.
It is an Xref material.
The material points toward a .max scene file where there are 60 box geometries.
Each box has applied on it a different standard material.
In this way on the main scene (where there is the Xref material):
-I load “box01” into the Xref material
-Launch Render
-Wait Render to finish
-Save render in .png format
-Load “box02” into the Xref material
-Launch Render
-Wait Render to finish
-Save render in .png format
-… and so on
I have to do this for multiple main scenes.
Thank you in advance for any kind of help.
Ps.
A clarification: in the .nax scene, which contains all the boxes, the boxes aren’t named “box01”, “box02” and so on, but they have the name of material, for example “wood_oak_cod.10” or “plastic_opaque_green”.
Seems like you want to make previews for 60 materials.
As I understood you have 60 boxes with 60 standard material on it. In render file you have same geometry for every render but each time it is one of those 60 materials applied as xref material . Every render saved as .png with some prefix and name of the material.
If so then for single scene it would be like:
(
--Get material from selected object
XrefMat = Selection[1].material
--Get list of objects from xref material source file
objList = getMAXFileObjectNames (XrefMat.srcFileName)
-- get how many objects in list
objList_count = objList.count
--disable undo, editing, scene redraw, change cursor
undo off
suspendEditing()
disableSceneRedraw()
setwaitcursor()
-- start progress bar
progressStart ("Rendering preview...")
renderSceneDialog.close()
for i =1 to objList_count do
(
XrefMat.srcItemName = objList[i]
escapeEnable = true
if (getProgressCancel()) == true then exit
progressUpdate (100.0*i/objList_count)
renderSceneDialog.close()
rendoutputfilename = ((getDir #renderoutput)+"\Preview_"+XrefMat.srcItemName+".png")
max quick render
--add ability to cancel batch
)
renderSceneDialog.open()
--end progressbar
--enable undo, editing, scene redraw, change cursor
progressEnd()
enableSceneRedraw()
resumeEditing()
undo on
setArrowCursor()
--message then all done
messagebox "All done" beep:on
)
By the way can anyone explain why script interrupt from second time?
for multiple main scenes :
(
fn renderPreview Xref_Material_Name =
(
--Get material by name
XrefMat = SceneMaterials[Xref_Material_Name]
--Get list of objects from xref material source file
objList = getMAXFileObjectNames (XrefMat.srcFileName)
-- get how many objects in list
objList_count = objList.count
--disable undo, editing, scene redraw, change cursor
undo off
suspendEditing()
disableSceneRedraw()
setwaitcursor()
-- start progress bar
progressStart ("Rendering preview...")
renderSceneDialog.close()
for i =1 to objList_count do
(
XrefMat.srcItemName = objList[i]
--escapeEnable = true
if (getProgressCancel()) == true then exit
progressUpdate (100.0*i/objList_count)
renderSceneDialog.close()
rendoutputfilename = ((getDir #renderoutput)+"\Preview_"+XrefMat.srcItemName+".png")
max quick render
--add ability to cancel batch
)
renderSceneDialog.open()
--end progressbar
--enable undo, editing, scene redraw, change cursor
progressEnd()
enableSceneRedraw()
resumeEditing()
undo on
setArrowCursor()
--message then all done
)
destinationDirectory = getSavePath caption:"Select folder with preview maxfiles: " \
destinationPathList = getFiles (destinationDirectory+"\\*.max")
for file in destinationPathList do
(
loadMaxFile file useFileUnits:on quiet:on
renderPreview "Material #0"
)
messagebox "All done" beep:on
)