Monday, January 3, 2022

Quick batch render

It always bothered me that Maya sets a global location for your batch renders. I always have that "Ok, where did my renders end up again?" moment, then copying the renders over to the correct path. I wanted to streamline this a bit, letting me choose my batch render location for each file. 


Of course it would be possible to just always render to that one images folder defined in the project settings and keep everything there. But I often want subfolders and adding them in the render settings is not that intuitive. Or I could set the images folder each time, but that's just a hassle.

The script itself is really basic, but does the job. First I ask the user where to save their render. Then I check what the active workspace is. If none exists I create one, if it does and is not under version control I check the current images folder and store it. If it is under version control I check it out. Then I change the images folder in the workspace.mel to the selected renderfolder and start a batch render.


When done I want to revert any changes we made to the workspace file (since the workspace file is shared) My first thinking was to start the batch and then on the next line just revert the changes. No dice, the default workspace location was used. But Maya batch is an external process, so I have no way of checking the batch render status from Maya. I tried printing the output of my Script Editor history to a txt file in my temp folder and every 5 seconds check if "*Render Completed*" appeared, I tried checking the render logs but they either froze up Maya or just didn't work properly. What I came up with is kinda hacky, but does the job (starting to notice a trend here 😂)

        string $batchRunning = `system ("tasklist | findstr /R ^mayabatch.exe")`;

    while (`size $batchRunning` != 0){
        $batchRunning = `system ("tasklist | findstr /R ^mayabatch.exe")`;
        pause -sec 1;
    }


So after this loop is done I revert the workspace file and give the user a confirm dialog that the render is done. Only drawback is that Maya is locked until the rendering is done, something that a regular batch render doesn't do, but I still prefer this to copying over files etc. Coffee anyone?

** Update. Since the workflow described above does freeze up your machine I revisted it, now it creates a simple batch file with the selected output folder and runs that

No comments:

Post a Comment