Render events example

This script shows how to register render events within a script.

Example
// This script shows how to register render events within a script

var mxsPath = "C:\test_scene.mxs";
var imagePath = "C:\test_render.png";
Maxwell.print( "rendering Mxs file: " + mxsPath );
Maxwell.openMxs( mxsPath );
Scene.setSamplingLevel( 5 );
Scene.setResX( 256 );
Scene.setResY( 256 );
Scene.setImagePath( imagePath );

RenderEvents["renderFinished()"].connect(renderHasFinished);
RenderEvents["samplingLevelChanged(double)"].connect(slHasChanged);
RenderEvents["renderError"].connect(errorHappened);
RenderEvents["renderWarning"].connect(warningHappened);

Maxwell.startRender();

function renderHasFinished()
{
   Maxwell.print( "Render finished!!" );
}

function slHasChanged(sl)
{
   Maxwell.print( "Script Info: SL Changed: " + sl );

   // Copy the current image with this SL to a different location
   var imagePathAtSL = FileManager.getFileFolder( imagePath ) + FileManager.getFileName( imagePath ) + "_sl_" + sl + ".png";
   FileManager.copy( imagePath, imagePathAtSL );
}
function errorHappened(err)
{
   Maxwell.print( "Script Info: Render Error: " + err );
}
function warningHappened(warning)
{
   Maxwell.print( "Script Info: Render Warning: " + warning );
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////

 

Â