We are happy to bring before you our latest addition to the Maverick arsenal: support for Python scripting.
Note that this post will get into some technical details, but we have created some pre-made scripts for you so you can carry out some typical tasks (e.g., batch rendering of cameras or scenes) without having to learn coding or write a single line of Python code. We encourage the most tech-savvy of you to learn more and discover the formidable power-tool that Python scripting in Maverick is.
Anyway, the main take-away of this new feature is covered by this video. It’s an easy watch:
Python scripting in Maverick Studio
Python is a (or possibly, the world’s most popular) scripting language.
We have added a new panel in Maverick Studio where you can write your own Python code, import pre-existing .py files, or simply use one of the pre-made scripts included in the Maverick installer. Then there is a Run button with which you can fire up your code.
In particular, in this release we have included scripts for batch rendering.
Batch rendering with Python
As you may know, Maverick Studio features a Command-Line Interface (CLI) tool called RenderWarrior which allows you to load and render a scene. RenderWarrior provides some interesting low-level features, such as the ability to alter attributes in the scene via command-line arguments. But RenderWarrior has basically three shortcomings:
Most people do not feel comfortable at all dealing with a command prompt, writing .bat files, etc…
Maverick has evolved a lot on the UI side in the past year and some high-end features involving render-loops such as turntables, PSD output with embedded shadows, etc… are only supported from the UI.
RenderWarrior provides a generous list of functionalities via the command-line. But scripting offers those, and so much more.
Heavy-duty batch rendering is a key feature to some of our customers. And even for those not rendering tens or hundreds of renders per batch, it is always a desirable feature to render a bunch of scenes or scene cameras back-to-back. So all in all, batch rendering is a feature that is brought up very often in support. Adding support for scripting has been in our roadmap for some time, and Python was our choice for a language, due to its popularity and flexibility.
Python can be used for anything. But batch rendering is a major and obvious possible use in the context of rendering. So in this release we provide some pre-made Python scripts to:
Render the active camera in all the scenes in a directory.
Render all the cameras in all the scenes in a directory.
Render all the turntables in all the scenes in a directory.
Rendering all the cameras in the current scene.
Does this mean that RenderWarrior becomes obsolete? In practical terms, yes, because Python scripting is more comfortable and can do plenty of things that RenderWarrior can’t. However, RenderWarrior is an integral part of our core and our internal Unit Testing system, so there are no plans to retire it whatsoever. It will stay as a more light-weight alternative to scripting, and it is still the right choice for UI-less cases where Maverick is meant to run as a service (e.g., in a server).
Here is a themed case of use where multiple cameras were configured in this keyboard scene. The Python script to batch-render all the cameras was used here.
This section is for the most curious of you and can be skipped for those who prefer to stick to the pre-made scripts without diving in the complexities of scripting.
Our implementation of Python scripting within Maverick fully supports Python 3.9, and the glue between the Python-side and the Maverick-side is an embedded Python library that interfaces with our C++ API, which we called MK_api (just like our C++ API is also called MK_api). So scripts interfacing with Maverick need to be headed with an import MK_api statement.
MK_api provides all the functions needed to set/get values in the scene graph (the DAG). We take pride in saying that the Python MK_api interface can do the job with just a handful of functions, so it is easy to master. You can list those functions with the statement MK_api.help(). The pre-made scripts included in the installer (accessible directly from the new Python panel) also feature some self-documentation, which may get you started in your first steps.
The names of nodes (about 100) and their attributes (over 5000) currently supported by Maverick can be viewed by inspecting any .mks file. However we plan to add some more accessible/explicit documentation of those in the Help panel or via tooltips. This will happen, quite possibly, in the next build(s).
For deeper details, do not hesitate to contact us.
If you need to automate a particular task, feel free to contact us. Depending on how generic/specific or easy/complex the request is, we may help you out, or even do bespoke scripting if required.
Of course, if you have suggestions for us to include other convenient pre-made scripts, feel free to let us know.
Pushing forward: improvements & fixes
Like every release, we try to improve or fix everything that gets reported on support. As usual, our changelog displays a list with every improvement or fix worth mentioning.
In this build for example we have fixed Region Render, which is now finally “elastic” in the sense that despite you select areas in the IPR at a restricted resolution, now the region will stretch up proportionally to cover the corresponding region to its final position when doing final resolution renders.