Script panel
The core rendering application now supports scripting. Scripting makes it much easier to automate tasks such as processing several MXI files at once, editing Multilight™ in animations, or launching sets of scenes changing their render parameters. All the parameters of the Maxwell Render UI are accessible through scripts.
The Maxwell Render scripting engine is based on ECMA standards (like other popular scripting languages such as Javascript and Actionscript), and provides default compatibility with these standards. The script editor in Maxwell Render also contains a Debugger, including breakpoints, searches, info about the variables, and more.
To learn more about the Script language in Maxwell, see the Scripting section.
The Script tab
Write a script in a simple text editor, save it with the .ms extension or even with the .js extension, and run it in Maxwell Render using the Run Script button in the Render Toolbar. It is also possible to launch a script through the command line using the argument -script:script_path, or to directly write a script in the Script Editor in the Script Tab.
You can choose between several example script pre-sets for the most common tasks.
These script pre-sets are available from the main menu (Scripting menu\ Scripts).
The Script panel shows a number of icons:
• Load Script File: Load a script file in .ms or .js format and open it in the Script Editor. Script files can be drag and dropped to the Viewer area or to the Script Editor to load them.
• Save Script File: Save the current script in .ms or .js format.
• Run Script: Run the script currently open in the Script Editor.
• Debugger: Open the script Debugger window.
• Find: Find a word in the script.
• Undo and Redo: Undo or Redo the last changes in the script.
The Script debugger window
How does it work
When writing a script, the autocomplete feature offers easy access to the main functionalities. When typing the keywords “Maxwell”, “Scene” or “MXI”, the Script Editor will display a dropdown list, giving you access to all the available commands to control the Maxwell engine, the scene settings or the MXI settings respectively.
Example
This simple script accesses all the MXS scenes in a folder and its subfolders, changes the scenes’ render settings, renders them and saves the output image in the specified location. You can change the commands and use the autocomplete help to explore all capabilities.
// This script gets all the mxs's located in the folder "input" and its children
// Opens them, change their SL and resolution and launch each render
// The output of all the images are stored in the folder "output"
var inputFolder = "C:\input";
var outputFolder = "C:\output";
var engineVersion = Maxwell.getEngineVersion();
var mxsCount = FileManager.getNumberOfFilesInBranch( inputFolder, "*.mxs" );
var mxsList = FileManager.getFilesInBranch( inputFolder, "*.mxs" );
RenderEvents["renderFinished()"].connect(renderHasFinished);
var i = 0;
var isRendering = 0;
for( i = 0; i < mxsCount; i++ )
{
renderScene();
while( 1 )
{
if( isRendering == 0 )
{
break;
}
}
}
//////////////////////////////////////////////////////////////////
function renderScene()
{
var mxsFile = mxsList[i];
var imagePath = outputFolder + "\" + FileManager.getFileName( mxsFile ) + ".png";
var mxiPath = outputFolder + "\" + FileManager.getFileName( mxsFile ) + ".mxi";
Maxwell.print( "rendering Mxs file: " + mxsFile );
Maxwell.openMxs( mxsFile );
Scene.setImagePath( imagePath );
Scene.setMxiPath( mxiPath );
Scene.setSamplingLevel( 8 );
Mxi.setResX( 400 );
Mxi.setResY( 400 );
//Scene.setTime( 10 );
isRendering = 1;
Maxwell.startRender();
}
//////////////////////////////////////////////////////////////////
function renderHasFinished()
{
isRendering = 0;
Maxwell.print( "Render finished!!" );
}
//////////////////////////////////////////////////////////////////