PySbs batchtools module
The PySbs batchtools module allows you to call the different command line tools like ordinary python commands.
batchtools module batchtools api reference.
The batchtools module wraps subprocess.Popen and makes it possible to use different command options as native arguments in python. The common structure of a batchtool is:
It is important to call .wait() on the returned process handle before using any output data from the command.
ref-to-demobatchtools Examples which demonstrates an automated pipeline using a mesh with udims.
For some batchtools it can be an advantage to retrieve information from the output of the process. As instance batchtools.sbsbaker_info output is very useful to retrieve mesh information like udims or color id but the process management and the information parsing may become painful. That’s why SAT introduced some OutputHandlers to handle this for you. An OutputHandler become the result of a bachtools call instead of a Popen object. The OutputHandler digests the process and its output to give an usable object depend of the batchtool.
More details on the different OutputHandlers and it’s associated objects :
SbsRenderOutputHandler output_handlers module
SbsRenderGraphStruct sbsrender_render_handlers module
SbsBakerInfoOutputHandler output_handlers module
SbsBakerInfoEntityStruct sbsbaker_info_handlers module
render animation sequence
As part of batchtools there is also sbsrender_render_animate function that allows you to render an image sequence. sbsrender_render_animate renders an image sequence from an sbsar input using sbsrender. It takes a start frame, an end frame and frames per second. The sbsrender command line tool will be called once for each frame.
By default the $time parameter will be generated for each frame based on start, end and fps. It is also possible to set pass in other sbsrender parameters globally.
To animate other parameters than $time sbsrender_render_animate has the animated_parameters argument . This argument allow to pass a list of pairs of parameter names and functions taking frame and fps as parameters allowing you to generate them over the image sequence.
More details about the different arguments on the api reference page batchtools module
This example renders 51 frames with a frame rate of 24. Note that the output_name value has a sequence padding looking like ### to specify the frame name in the filename. In this example the animated_parameters is used to tweak the input parameter over time using a lambda function taking the two arguments frame and fps
Sometimes it could be great to only query the command line without execute it. As instance all the batchtools commands could be “starting” on the user local machine but not executed instead all the commands are written in a file that will be executed later by a renderfarm. Simple example:
Generate thumbnails with SAT Thumbnail creation with SAT