Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

• 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.

...

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.

Code Block
languagejs
// These lines are comments
// Make massive changes in MXS files and launch them to render
// This script allows you to access gets all the MXSmxs's located in the folder "inputFolderinput" and its subfolderschildren
// OpenOpens the scenesthem, change their SL and resolution and launch theeach render(s)
// The output of all the images isare stored in the folder "outputFolderoutput" in Tiff
format.

var inputFolder = "C:\\ set the input folder";
var outputFolder = "C:\\ set the output folder";

var engineVersion = Maxwell.getEngineVersion();

var mxsCount =  MaxwellFileManager.getNumberOfFilesInBranch( inputFolder, "*.mxs" );
var mxsList = MaxwellFileManager.getFilesInBranch( inputFolder, "*.mxs" );
for( 

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.setSamplingLevelsetImagePath( 12imagePath );
   Scene.setResXsetMxiPath( 1024mxiPath );

  Scene.setResYsetSamplingLevel( 7688 );
  Mxi.setResX( var400 imagePath);
= outputFolder + "\\" + Maxwell.getFileName( mxsFile ) + "_" + engineVersion + ".tiff";
   Scene.setImagePath( imagePath );

Mxi.setResY( 400 );
//Scene.setTime( 10 ); 

  isRendering = 1;
  Maxwell.startRenderAndWaitstartRender();
}

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

function renderHasFinished()
{
  isRendering = 0;

  Maxwell.print( "Render finished!!" );
}

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