All posts related to V3
#389442
hi,

I have a mxs file with several cameras (as a result of an export from a sketchup file with several scenes) and I have this script:
Code: Select all
// This script gets all the mxs's located in the folder "input"
// Renders them until a desired Initial SL, to get a first version of the whole sequence, allowing the user to start the postproduction process
// Then continues refining the sequence until the Final SL, advancing in certain steps (slStep), offering continuous refinement


// Edit the following lines with your own project Input and Output folders

var inputFolder = "C:\directory";
var outputFolder = "C:\directory\output";

var mxsCount = FileManager.getNumberOfFilesInFolder( inputFolder, "*.mxs" );
var mxsList = FileManager.getFilesInFolder( inputFolder, "*.mxs" );

RenderEvents["renderFinished()"].connect(renderHasFinished);

// The following SL values can be customized to fit your needs

var initialSL = 8;
var finalSL = 16;
var slStep = 2;
var currentSL = initialSL;


var i = 0;
var isRendering = 0;

while( currentSL <= finalSL )
{
for( i = 0; i < mxsCount; i++ )
{
renderScene();
while( 1 )
{
if( isRendering == 0 )
{
break;
}
}
}

currentSL += slStep;
}



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

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( currentSL );
// Uncomment the following lines if you want to set a different resolution than the indicated in the MXS scene file
Mxi.setResX( 1200 );
Mxi.setResY( 588 );
Scene.setResumeRenderEnabled( true );

isRendering = 1;
Maxwell.startRender();
}

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

function renderHasFinished()
{
isRendering = 0;

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

//////////////////////////////////////////////////////////////////
How should the script be modified, so that I have to specify a mxs-file and the script will render all the cameras within the mxs-file (instead of rendering the active camera of various mxs within a folder?

thx for your support
#389456
thank you for the hint, it was a great help.
I was able to merge the animation and progressive scripts, now I have a script that significantly improve my workflow.
Maybe someone is also looking for such a script:
Code: Select all
var firstSceneIndex = 1;
var lastSceneIndex = 3;
var baseName = "S";
var inputFile = "C:\Users\Daniel\Desktop\ScriptTest\SketchupFile.mxs";
var outputFolder = "C:\Users\Daniel\Desktop\ScriptTest\output";
var initialSL = 2;
var finalSL = 8;
var slStep = 1;
var currentSL = initialSL;
var i = 0;
var isRendering = 0;
var currentSceneIndex = firstSceneIndex;

RenderEvents["renderFinished()"].connect(renderHasFinished);
Maxwell.clearConsole();

//////////////////////////////////////////////////////////////////
while( currentSL <= finalSL )
{
	currentSceneIndex = firstSceneIndex;
	renderScene();
    while( 1 )
    {
      if( isRendering == 0 )
      {
          break;
      }
    }

  currentSL += slStep;
}



//////////////////////////////////////////////////////////////////
function renderScene()
{
while (currentSceneIndex <= lastSceneIndex)
{
  renderCamera(currentSceneIndex);
  while(1)
  {
    if(isRendering == 0)
    {
        break;
    }
  }
  currentSceneIndex++;

}
} 


//////////////////////////////////////////////////////////////////
 
function renderCamera(frameNumber)
{
  var sceneName = baseName + frameNumber;
  Maxwell.openMxs( inputFile );
  var imagePath = outputFolder + "\" + sceneName + ".png";
  var mxiPath = outputFolder + "\" + sceneName + ".mxi";
  
  Mxi.setActiveCamera(sceneName);
  if (Mxi.activeCameraName != sceneName)
  {
    Maxwell.print("The MXS contains no camera named '" + sceneName + "'!");
  }
  else
  {
    Maxwell.print("rendering Scene: " + sceneName + " until SL " + currentSL);
    Scene.setMxiPath( mxiPath);
    Scene.setImagePath( imagePath );   
	Scene.setSamplingLevel( currentSL );
	Mxi.setResX( 1600 );
	Mxi.setResY( 784 );
	Scene.setResumeRenderEnabled( true );
    isRendering = 1;
    Maxwell.startRender();
  }
}
 
//////////////////////////////////////////////////////////////////

function renderHasFinished()
{
  isRendering = 0;

  Maxwell.print( "Render finished!" );
}
for the future it would be great to set the active camera by an index and not only by name :)
I found a python script to read out the camera names but I was not able to "translate" it in a maxwell script.
Code: Select all
##################################
# Copyright 2014 Rodman
##################################

from pymaxwell import *

def getCameras(mxs_path):
   scene = Cmaxwell(mwcallback)
 
   ok = scene.readMXS(mxs_path)
   if ok == 0:
      print("Error reading " + mxs_path)
   else:
      print("MXS (" + mxs_path + ") read")

   it = CmaxwellCameraIterator()
   camera = it.first( scene )
   while not camera.isNull():
      print(camera.getName())
      camera = it.next()

   scene.freeScene()

getCameras("c:/input/scene.mxs")
Will there be a Maxwell Render 6 ?

Although i’ve been happily rendering away in[…]

SS Pinto Bean

Hi Tommy, Great stuff - love it~! Thanks for pos[…]

Never No More Studio Lighting

Hello Mark! Very good tips about the camera setti[…]

Sadly, this lack of a response demonstrates a mori[…]