Page 1 of 3
scripting question
Posted: Sun Aug 20, 2017 10:07 pm
by seghier
hello i have two question about scripting:
- is it possible to get the cameras count in the mxs file ?
- how this function used : Scene.commandLine ?
the documentation isn't clear and don't give detailed informations or examples of every function
Re: scripting question
Posted: Mon Aug 21, 2017 10:52 am
by luis.hijarrubia
I recommend to change to PyMaxwell, witch also es better documented (for example, pressing F1 on Cmaxwell word will open a window with all functions and there it is a getCamerasCount method), but mainly because the "javascript" intepreter on maxwell.exe is provided by QT and it's deprecated, so on next QT version will disappear and it will disappear from maxwell too.
Re: scripting question
Posted: Mon Aug 21, 2017 3:24 pm
by seghier
thanks Luis
i will try ; i have no idea about python and how use pymaxwell
Re: scripting question
Posted: Mon Aug 21, 2017 5:57 pm
by seghier
luis.hijarrubia wrote: ↑Mon Aug 21, 2017 10:52 am
I recommend to change to PyMaxwell, witch also es better documented (for example, pressing F1 on Cmaxwell word will open a window with all functions and there it is a getCamerasCount method), but mainly because the "javascript" intepreter on maxwell.exe is provided by QT and it's deprecated, so on next QT version will disappear and it will disappear from maxwell too.
in pymaxwell : getCamerasCount() but no clear explanation how to use it
Help on method Cmaxwell_getCamerasCount in module _pymaxwell4:
Cmaxwell_getCamerasCount(...) unbound pymaxwell.Cmaxwell method
Method: getCamerasCount() -> (int,ok)
Description: Returns the number of cameras in the scene
Re: scripting question
Posted: Mon Aug 21, 2017 7:10 pm
by Mihai
Well, a course in Python is beyond the scope of the pymaxwell docs. I guess you would assign the value it returns to a variable. Something like:
yourscene = Cmaxwell(mwcallback);
yourscene.readMXS('myscene.mxs');
nrofcams = yourscene.getCamerasCount();
(I have next to no knowledge on python, so please no further questions

)
Re: scripting question
Posted: Mon Aug 21, 2017 7:28 pm
by seghier
thanks Mihai
i create this but always an error ( question not for you

)
from pymaxwell import *
scene = Cmaxwell(mwcallback);
scene.readMXS(
'c:/input/t.mxs');
nrofcams =
'c:/input/t.mxs'.getCamerasCount();
Traceback (most recent call last):
File "<string>", line 8, in <module>
AttributeError: 'str' object has no attribute 'getCamerasCount'
Re: scripting question
Posted: Mon Aug 21, 2017 9:24 pm
by Mihai
You would use scene.getCameraCount() I think, not the name of the scene file again. "scene" effectively becomes whatever you've already specified with the scene.readMXS method. From then on, you use all the methods available to the "scene" object, it is implied that this object refers to "t.mxs".
Re: scripting question
Posted: Mon Aug 21, 2017 9:33 pm
by seghier
thanks Mihai
yes i tried that and the error message disappear
now how this script can show the number of cameras ?
Re: scripting question
Posted: Mon Aug 21, 2017 10:39 pm
by seghier
this is the script , thanks for help:
from pymaxwell import *
scene = Cmaxwell(mwcallback);
scene.readMXS('mxs location');
print scene.getCamerasCount()
or
from pymaxwell import *
scene = Cmaxwell(mwcallback);
scene.readMXS('mxs location');
value = scene.getCamerasCount();
print value
the result : (3, True) { 3 : cameras number } ; how i can choose the number only ?
can script in maxwell render use script from pymaxwell ?
Re: scripting question
Posted: Mon Aug 21, 2017 11:01 pm
by seghier
the script {run_maxwell_render.py} always give error :
MAXWELL3_ROOT environment variable not found!
Traceback (most recent call last):
File "<string>", line 29, in <module>
File "<string>", line 23, in run_maxwell_render
File "C:\Program Files\Next Limit\Maxwell Render 4\python\python\lib\site-packages\pymaxwell\__init__.py", line 127, in runMaxwell
parameters.insert(0,mwroot+'/maxwell.exe');
UnboundLocalError: local variable 'mwroot' referenced before assignment
Re: scripting question
Posted: Mon Aug 21, 2017 11:15 pm
by seghier
the script again : cameras number
this will give the number only :
Code: Select allfrom pymaxwell import *
scene = Cmaxwell(mwcallback);
scene.readMXS('c:/input/t.mxs');
n,ok = scene.getCamerasCount()
print str(n);
Re: scripting question
Posted: Tue Aug 22, 2017 3:54 am
by seghier
the help of pymaxwell ; i hope add more examples and explanation
how setActive for camera used ?
Re: scripting question
Posted: Tue Aug 22, 2017 11:24 am
by luis.hijarrubia
it's done in the camera object.
something like:
CmaxwellCamera camera = //code to get the camera you want
camera.setActive();
Re: scripting question
Posted: Tue Aug 22, 2017 12:01 pm
by seghier
thanks Luis
the question about the code ?
//code to get the camera you want
i create code to count cameras number and separate them by name or number
and i want know how i can render each camera view ; this is simple in maxwell render script
Code: Select allfrom pymaxwell import *
scene = Cmaxwell(mwcallback);
scene.readMXS('c:/input/maison.mxs')
### 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)
Re: scripting question
Posted: Tue Aug 22, 2017 12:20 pm
by seghier
CmaxwellCamera
camera = scene.getCamera( 'name' )
camera.setActive();