Announcement

Collapse
No announcement yet.

Read frame number from VFB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Read frame number from VFB

    Is there a way to read the frame number that is currently rendering from V-Ray's VFB? I would like to use that value to drive the file output name.

    Here is the code that I am using as a pre-render script. It works only for the current frame that is set in the 3ds Max time slider.

    Code:
    mat = sceneMaterials["myMat"] /*Material to get names*/
    matNo = (mat.switchNum as integer)
    matObj = mat.switchMtl
    f = currentTime.frame /*??? want to get frame number that is currently rendering*/
    matName = matObj[f+1].name
    
    rendSaveFile = true
    fileLoc = "C:/Users/xyz/Desktop/"
    fileExt = ".png"
    rendOutputFilename = fileLoc + matName + fileExt​
    Found solution to read out which frame number is rendering, but still can't get that value into Pre-render script.

    Code:
    fn myCallback = currentTime.frame as integer
    callbacks.addScript #prerenderframe myCallback id:#myCtCallback​



    I appreciate any help!

  • #2
    The reason it doesn't work is that, unlike Maya, in 3ds Max there isn't a "Pre-render frame" script (only pre-render, which happens once even for animations). Also, note that the Render Setup has an old issue, which does not let MaxScript refresh the render settings. It is bypassed by passing a renderSceneDialog.close() and renderSceneDialog.open() line.

    I modified your script so that it works without the need for a pre-render script. It works as a "manual" animation rendering, running the script after every frame:

    Code:
    fn manualAnimationRender = (
    
    startFrame = 0
    endFrame = 2
    
    for i = startFrame to endFrame do (
    renderSceneDialog.close()
    slidertime = i
    rendTimeType = 1
    mat = sceneMaterials["myMat"]
    matNo = (mat.switchNum as integer)
    matObj = mat.switchMtl
    f = currentTime.frame as integer
    matName = matObj[f+1].name as string
    
    rendSaveFile = true
    fileLoc = "C:\Users\xyz\Desktop\"
    fileExt = ".png"
    pngio.setType #true48
    pngio.setAlpha true
    rendOutputFilename = (fileLoc + matName + fileExt) as string
    
    renderSceneDialog.open()
    max quick render
    )
    )
    try (manualAnimationRender())catch()​
    You can check the pngio methods here.
    Also, note that for the script to work properly, the Time Output should be set to Single frame, hence why I've added the rendTimeType = 1 line.
    Last edited by hermit.crab; 19-08-2024, 01:46 AM.
    Aleksandar Hadzhiev | chaos.com
    Chaos Support Representative | contact us

    Comment

    Working...
    X