All posts related to V3
By lem0nayde
#389784
I have a sequence of MXS files (exported from RealFlow) in which vignetting is a problem. I've been trying to create a script that goes into each MXS file and sets the de-vignetting option ON with a value of 100%.

The best I've been able to do is modify the included script below which makes those changes and then renders to MXI -- but I just want the changes to be saved to the MXS file, I don't want it to render. I'm finding the documentation for scripting really difficult to follow. Any help is much appreciated.
Code: Select all

var inputFolder = "/";
var outputFolder = "/";

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 + "\PNG\" + FileManager.getFileName( mxsFile ) + ".png";
  var mxiPath = outputFolder + "\MXI\" + FileManager.getFileName( mxsFile ) + ".mxi";

  Maxwell.print( "rendering Mxs file: " + mxsFile );

  Maxwell.openMxs( mxsFile );
  Scene.setImagePath( imagePath );
  Scene.setMxiPath( mxiPath );
  Scene.setSamplingLevel( 1 );
  Scene.setTime( 9999 ); 
  Mxi.setVignettingEnabled( 1 );
  Mxi.setVignetting( 100 )

  isRendering = 1;
  Maxwell.startRender();
}

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

function renderHasFinished()
{
  isRendering = 0;

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

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


User avatar
By seghier
#389786
try with this script ( change c:/scenes/ with your own location of the mxs files )


from pymaxwell import *
mxslist = getFilesFromPath('c:/scenes/','mxs');
scene = Cmaxwell(mwcallback);
for file in mxslist:
scene.readMXS('c:/scenes/' + file);

scene.setRenderParameter( 'DO DEVIGNETTING', 1 );

scene.writeMXS('c:/scenes/' + file);
scene.freeScene();




--------
the DEVIGNETTING turned on but i don't know how to change the value
i tried with that :
scene.setRenderParameter( 'DEVIGNETTING', 100 );
but didn't work

original script here : http://support.nextlimit.com/display/pl ... n+Bindings
By lem0nayde
#389787
Thanks, this is a great start. It looks like DEVIGNETTING only works if you use "100.0" as in: scene.setRenderParameter('DEVIGNETTING', 100.0 );

My only problem now (albeit a big one) is that the script is emptying everything else out of my scene. How do I modify the below script so that it saves everything in the existing MXS and just adjusts Devignetting?
Code: Select all
################################################################
# Read all MXS in a folder, make some changes.
################################################################

from pymaxwell import *

def read_all_mxs_from_path():
	
	# Get all mxs from given path
	path = '/somepath/';
	mxslist = getFilesFromPath(path,'mxs');
	print(mxslist);

	# Create a new scene
	scene = Cmaxwell(mwcallback);
	
	# Read each MXS and makes some changes
	for file in mxslist:
		scene.readMXS( path + file);
		scene.setRenderParameter( 'DO DEVIGNETTING', 1 );
		scene.setRenderParameter('DEVIGNETTING', 100.0 );
		scene.writeMXS(path + '/Fixed/fixed-' + file);
		scene.freeScene();
	
	return 1;

read_all_mxs_from_path();

User avatar
By seghier
#389788
thanks this "100.0" solve the problem
try with this script : it will enable DEVIGNETTING and set the value to 100
Code: Select all
from pymaxwell import *
mxslist = getFilesFromPath('c:/scenes/','mxs');
scene = Cmaxwell(mwcallback);
for file in mxslist:
  scene.readMXS('c:/scenes/' + file);

  scene.setRenderParameter( 'DO DEVIGNETTING', 1 );
  scene.setRenderParameter( 'DEVIGNETTING', 100.0 );

  scene.writeMXS('c:/scenes/' + file);
  scene.freeScene();

I'll not be surprised to find that NL is done by n[…]

Haha, thanks.

Hello, I'm still waiting for a solution to the pro[…]