Everything related to Maxwell Render and general stuff that doesn't fit in other categories.
User avatar
By seghier
#395158
from pymaxwell import *

scene = Cmaxwell(mwcallback);
scene.readMXS('mxs_file')

### cameras number ###
n,ok = scene.getCamerasCount()
print (n);

### cameras name ####
list = scene.getCameraNames()
print (list)
for o in (list):
print (o)


### cameras ID #######
r = range(n)
print (r)
for o in reversed(r):
print(o)

################################

l = list
k=n-1
a = l[k-3]
b = l[k-2]
c = l[k-1]
d = l[k]
#print (c);


### active camera ######
CmaxwellCamera
camera = scene.getCamera(d)
camera.setActive();

### write mxs ##########
outPath = 'new_mxs_file'
ok = scene.writeMXS(outPath);

a = list
for i, val in enumerate(a):
print i, val
----------------------------------------------
i write the list a,b,c,d manually to use them as camera name
camera = scene.getCamera(d)
how i set every camera active and render all views automatically ?
User avatar
By seghier
#395161
luis.hijarrubia wrote:
Tue Aug 22, 2017 12:54 pm
Code: Select all
cameraNames = scene.getCameraNames()
for name in cameraNames:
  camera = scene.getCamera(name)
  camera.setActive()
  ##render code
thanks Luis that much easier
i add render code but nothing happened and i don't find any information how to add camera to render parameters.
-camera:name don't work
Code: Select all
def run_maxwell_render():

	parameters = []
	
	parameters.append('-mxs:'+'c:/input/t.mxs');
	parameters.append('-o:'+'c:/output'+'/t.png');
	parameters.append('-mxi:'+'c:/output'+'/t.mxi');
        [b]parameters.append('-camera:a');[/b]
	parameters.append('-res:300x200');
	parameters.append('-time:10');
	parameters.append('-sl:5');


	runMaxwell(parameters);
	return 1;

run_maxwell_render();
User avatar
By seghier
#395162
camera command work now . but the render don't detect the "name "
Code: Select all
from pymaxwell import *

scene = Cmaxwell(mwcallback);
scene.readMXS('c:/input/t.mxs')
cameraNames = scene.getCameraNames()
print (cameraNames)
for name in cameraNames:
  camera = scene.getCamera(name)
  camera.setActive()
outPath = 'c:/output'+'/'+'name.mxs'
ok = scene.writeMXS(outPath);


def run_maxwell_render():

	parameters = []
	
	parameters.append('-mxs:'+'c:/input/t.mxs');
	parameters.append('-o:'+'c:/output'+'/t.png');
	parameters.append('-mxi:'+'c:/output'+'/t.mxi');
	parameters.append('-res:300x200');
	parameters.append('-time:10');
	parameters.append('-sl:5');
	parameters.append('-camera:name');



	runMaxwell(parameters);
	return 1;



run_maxwell_render();
By luis.hijarrubia
#395164
The render part (inside the for)

parameters = []
parameters.append('-mxs:'+ "C:\temp\tmpMaterialScene.mxs")
parameters.append('-nowait');
parameters.append('-nogui');
parameters.append('-res:500x500');
scene.setMxsPath("C:\temp\tmpMaterialScene.mxs");
scene.writeMXS();
runMaxwell(parameters)

As you can see, you save a temp mxs and render it with each camera.
User avatar
By seghier
#395165
thank you Luis for help
i test the script and there are some problems
Code: Select all
from pymaxwell import *

scene = Cmaxwell(mwcallback);
scene.readMXS('c:/input/maison.mxs')
cameraNames = scene.getCameraNames()
for name in cameraNames:
  camera = scene.getCamera(name)
  camera.setActive()
  print name
  parameters = []

  parameters.append('-mxs:'+'c:/input/maison.mxs');
  parameters.append('-nowait');
  parameters.append('-nogui');
  parameters.append('-res:300x200');
  parameters.append('-s:6');
  scene.setMxsPath('c:/output');
  scene.writeMXS('c:/output/t_%camera%.mxs');
  parameters.append('-o:'+'c:/output'+'/t_%camera%.png');
  parameters.append('-mxi:'+'c:/output'+'/t_%camera%.mxi');
  parameters.append('-res:300x200');
  parameters.append('-time:10');

  runMaxwell(parameters)
-in the name of the new mxs : "t_%camera%.mxs" don't change
-the script print the name of every camera but maxwell render only the active one
----
Image
By luis.hijarrubia
#395166
You are right, you can do something like:

parameters.append('-o:'+'c:/output/t_'+ name + '.png');
parameters.append('-mxi:'+'c:/output/t_'+ name + '.mxi');
User avatar
By seghier
#395167
luis.hijarrubia wrote:
Tue Aug 22, 2017 5:08 pm
You are right, you can do something like:

parameters.append('-o:'+'c:/output/t_'+ name + '.png');
parameters.append('-mxi:'+'c:/output/t_'+ name + '.mxi');
no problem with png or mxi ; just the mxs file
and other cameras didn't rendered ; there are 4 cameras in the scene and the render repeat the same view 4 times
By luis.hijarrubia
#395168
I don't mind about mxs repeating name, as you render each before writing the next one, so you don't need to have them all.

Can you post the complete script so I can test why is not rendering different cameras.
User avatar
By seghier
#395169
thanks Luis
i fix it ; i add output of the new mxs file when camera changed before getcamera line than i use the new scene for render
this is the script ; and thank you very much for help.
Code: Select all
from pymaxwell import *

scene = Cmaxwell(mwcallback);
scene.readMXS('c:/input/maison.mxs')
cameraNames = scene.getCameraNames()
for name in cameraNames:
  outPath = 'c:/input/m.mxs'
  ok = scene.writeMXS(outPath);
  camera = scene.getCamera(name)
  camera.setActive()
 
  parameters = []
  parameters.append('-mxs:'+'c:/input/m.mxs');
  parameters.append('-nowait');
  parameters.append('-nogui');
  parameters.append('-res:300x200');
  parameters.append('-s:6');
  scene.setMxsPath('c:/output');
  #scene.writeMXS('c:/output/t_%camera%.mxs');
  parameters.append('-o:c:/output/t_%camera%.png');
  parameters.append('-mxi:c:/output/t_%camera%.mxi');
  parameters.append('-res:300x200');
  parameters.append('-time:10');
  runMaxwell(parameters)
User avatar
By seghier
#395170
the final code :

from pymaxwell import *

def render_all_cameras(inFolder,inPath,outFolder):

scene = Cmaxwell(mwcallback);
scene.readMXS(inPath)
cameraNames = scene.getCameraNames()
for name in cameraNames:
outPath = inFolder+'/'+'new.mxs'
ok = scene.writeMXS(outPath);
camera = scene.getCamera(name)
camera.setActive()

parameters = []
parameters.append('-mxs:'+outPath);
parameters.append('-nowait');
parameters.append('-nogui');
parameters.append('-res:300x200');
parameters.append('-s:6');
parameters.append('-o:'+outFolder+'/m_%camera%.png');
parameters.append('-mxi:'+outFolder+'/m_%camera%.mxi');
parameters.append('-res:300x200');
parameters.append('-time:10');
runMaxwell(parameters)


if __name__ == "__main__":
inFolder = 'input_folder'
inPath = 'input_mxs'
outFolder = 'output_folder'
render_all_cameras(inFolder,inPath,outFolder);
Code: Select all
from pymaxwell import *

def render_all_cameras(inFolder,inPath,outFolder):

  scene = Cmaxwell(mwcallback);
  scene.readMXS(inPath)
  cameraNames = scene.getCameraNames()
  for name in cameraNames:
    outPath = inFolder+'/'+'new.mxs'
    ok = scene.writeMXS(outPath);
    camera = scene.getCamera(name)
    camera.setActive()
 
    parameters = []
    parameters.append('-mxs:'+outPath);
    parameters.append('-nowait');
    parameters.append('-nogui');
    parameters.append('-res:300x200');
    parameters.append('-s:6');
    parameters.append('-o:'+outFolder+'/m_%camera%.png');
    parameters.append('-mxi:'+outFolder+'/m_%camera%.mxi');
    parameters.append('-res:300x200');
    parameters.append('-time:10');
    runMaxwell(parameters)


if __name__ == "__main__":
   inFolder = 'input_folder'
   inPath = 'input_mxs'
   outFolder = 'output_folder'
   render_all_cameras(inFolder,inPath,outFolder);
User avatar
By seghier
#395177
luis.hijarrubia wrote:
Wed Aug 23, 2017 10:55 am
seghier wrote:
Tue Aug 22, 2017 6:22 pm
the final code :
Does that work? As i see you set the active camera after saving and not before.
Yes worked fine
Because after se the active camera the new mxs file is always the same as the original file
Before set active camera it save a new scene with different view
I don't know why after set active camera the script don't change the view
You can test the two versions
Will there be a Maxwell Render 6 ?

Let's be realistic. What's left of NL is only milk[…]