Chaos Corona Forum

Chaos Corona for 3ds Max => [Max] I need help! => Topic started by: HMValin on 2023-02-02, 07:40:04

Title: How to save the wireframe render images from the CTexmap in RenderElements?
Post by: HMValin on 2023-02-02, 07:40:04
Hello, I need help saving the wireframe image generated when rendering. I made a script to automate the process of rendering multiple assets at the same time. In the script, the user can choose which folder to save the renders and the name of the .jpeg file is updated with a loop, so that the file does not overlap with the previous one. However, the wireframe image does not have its name updated and is not being saved in the folder chosen by the user. Is there any way to change this?

Explaining the code:



Code: [Select]
rendSaveFile = true

_frame = 0

studioFile = getOpenFileName caption: "Select the Studio Asset"
loadMaxFile studioFile

directoryParent = getSavePath caption: "Select the Parent Directory"

dirPath = directoryParent + "\*"
dirList = getDirectories dirPath
print dirList

renderPath = getSavePath caption: "Select a Folder to Save the Renders"

for dir in dirList do(

assetsPath = dir + "\*.max"
assetsList = getFiles assetsPath
print assetsList

for current in assetsList do(

xrefs.addNewXRefFile current
currentName = getFilenameFile current
makeDir (renderPath + "\\" + currentName)
finalPath = (renderPath + "\\" + currentName)

for c in cameras where classof c != Targetobject do(

render camera:c outputfile:(finalPath + "\\" + currentName + "_" + c.name + "_" + ".jpeg")

if c.name == "CAM_RENDER_TURN" then(

makeDir (finalPath + "\\" + "360")
turnPath = (finalPath + "\\" + "360")
render camera:c fromframe:0 toframe:10 outputfile:(turnPath + "\\" + currentName + "_" + _frame as string + ".jpeg")
_frame += 1

)

)

xrefs.deleteAllXRefs()

)

)
Title: Re: How to save the wireframe render images from the CTexmap in RenderElements?
Post by: Avi on 2023-02-08, 09:09:04
Hi,

The problem in your code is that you are calling your studio file only 1 time for every asset so the render paths are getting overwritten. I made some changes to your code and looped the studio file to be opened seperately for every asset and save the renders according to camera names.

Here is the code:

Code: [Select]
rendSaveFile = true

_frame = 0

studioFile = getOpenFileName caption: "Select the Studio Asset"

directoryParent = getSavePath caption: "Select the Parent Directory"

dirPath = directoryParent + "\*"
dirList = getDirectories dirPath
print dirList

renderPath = getSavePath caption: "Select a Folder to Save the Renders"

for dir in dirList do(

assetsPath = dir + "\*.max"
assetsList = getFiles assetsPath
print assetsList

for current in assetsList do(

loadMaxFile studioFile
xrefs.addNewXRefFile current
currentName = getFilenameFile current
currentAssetPath = (renderPath + "\\" + currentName)
makeDir currentAssetPath

for c in cameras where classof c != Targetobject do(

currentRenderPath = (currentAssetPath + "\\" + c.name)
makeDir currentRenderPath
render camera:c outputfile:(currentRenderPath + "\\" + currentName + "_" + c.name + ".jpeg")

if c.name == "CAM_RENDER_TURN" then(

turnPath = (currentRenderPath + "\\" + "360")
makeDir turnPath
render camera:c fromframe:0 toframe:10 outputfile:(turnPath + "\\" + currentName + "_" + _frame as string + ".jpeg")
_frame += 1

)

)

xrefs.deleteAllXRefs()

)

)

I hope this helps.