Page 1 of 1

Pymaxwell and python 3.5

Posted: Thu Oct 05, 2017 9:11 am
by seghier
Hello
i switch from python 2.7 to 3.5 and i copied pymaxwell from python3.5 folder with _ini_.py file because it didn't work without it; and the problem when i tried to open mxs scene the script crash .
the same code work fine with v2.7 ;
left: python 3.5 / right: python 2.7
Image

Re: Pymaxwell and python 3.5

Posted: Thu Oct 05, 2017 11:06 am
by seghier
i download pyqt5 for python 2.7 ; i don't know why python 2.7 show the errors but other versions just crash without any information.
and the errors :
ok = scene.readMXS(self.edit_input_file.text(), Cmaxwell.SKIP_OBJECTS);
TypeError: in method 'Cmaxwell_readMXS', argument 2 of type 'char const *'

ok = scene.readMXS(mxsList);
TypeError: in method 'Cmaxwell_readMXS', argument 2 of type 'char const *'

Re: Pymaxwell and python 3.5

Posted: Fri Oct 06, 2017 7:30 am
by seghier
problem solved ; with pyqt5 and python2.7 readMxs and writeMxs must add str()
but with pyqt5 and python 3.5 always problem in readMxs() ; even i use str()

scene.readMXS(mxsList) >> [python 2.7 / pyqt4] work
scene.readMXS(str(mxsList)) >> [python 2.7 / pyqt5] work
scene.readMXS(mxsList) or scene.readMXS(str(mxsList)) >> [python 3.5 / pyqt5] crash

Re: Pymaxwell and python 3.5

Posted: Fri Oct 06, 2017 8:43 am
by seghier
when i run the script from terminal i got this error :

Warning: Warning in Method = readMXS
error = Path is NULL or Empty
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "maxwell_toolv6.py", line 1842, in openMxmSorA
self.MXMopenMxs()
File "maxwell_toolv6.py", line 1870, in MXMopenMxs
ok = scene.readMXS(str(mxsList)) { or ok = scene.readMXS(mxsList)}
SystemError: <built-in function Cmaxwell_readMXS> returned a result with an error set

Re: Pymaxwell and python 3.5

Posted: Fri Oct 06, 2017 2:38 pm
by Brany
can you print the value of str(mxsList)? If it is a list, you must select one of the paths, readMXS does not admit a list of MXS paths ;)

Re: Pymaxwell and python 3.5

Posted: Fri Oct 06, 2017 2:48 pm
by seghier
yes of course it's one file ; mxsList it just a name
with python 2.7 work fine but with python 3.5 i got the error posted above and with python 3.5 detect mxsList or str(mxsList) as empty
Image

Re: Pymaxwell and python 3.5

Posted: Fri Oct 06, 2017 5:27 pm
by seghier
everytime when i solve problem i find another !
with pyqt5 and python 3.5 some lines need new arrangement and that solve the problem of readMXS()
and now the problem with render parameter ; i used str(Re) but don't work
nn = self.engine_choice.currentIndex()
Code: Select all
if nn == 0:  # CPU production
                Re = 'RS1'
            elif nn == 1:  # CPU draft
                Re = 'RS0'
            elif nn == 2:  # GPU
                Re = 'RSC'
            scene.setRenderParameter('SAMPLING LEVEL', sl)
            scene.setRenderParameter('STOP TIME', st)
            scene.setRenderParameter('DO NOT SAVE MXI FILE', self.check_mxi.isChecked()==False and 1)
            scene.setRenderParameter('DO NOT SAVE IMAGE FILE', self.check_img.isChecked()==False and 1)
            scene.setRenderParameter('DENOISE ENABLED', self.enable_denoiser.isChecked() and 1)
            scene.setRenderParameter('DENOISE SHADOW', self.den_shad.isChecked() and 1)
            scene.setRenderParameter('DENOISE GPU', self.use_gpu.isChecked() and 1)
            scene.setRenderParameter('DO MOTION BLUR', self.motion_blur.isChecked() and 1)
            scene.setRenderParameter('DO DISPLACEMENT', self.displacement.isChecked() and 1)
            scene.setRenderParameter('DO DISPERSION', self.dispersion.isChecked() and 1)
            scene.setRenderParameter('ENGINE', Re)
and the error message :
Traceback (most recent call last):
File "maxwell_toolv6.py", line 791, in render
self.rendering()
File "maxwell_toolv6.py", line 935, in rendering
scene.setRenderParameter('ENGINE', Re)
SystemError: <built-in function Cmaxwell_setRenderParameter> returned a result with an error set

Re: Pymaxwell and python 3.5

Posted: Sat Oct 07, 2017 12:42 am
by seghier
tets with the name of the engine: scene.setRenderParameter('ENGINE', 'RS0') ; but the same error
other parameters work fine

Image

if i use : scene.setRenderParameter('ENGINE', str(RS0)) ; the error : scene.setRenderParameter('ENGINE', str(RS0)) // NameError: name 'RS0' is not defined

Re: Pymaxwell and python 3.5

Posted: Tue Oct 10, 2017 5:38 pm
by Brany
I found what is happening. This methods expects "bytes" instead of a "str", so you have to call it his way in Python 3.x:
Code: Select all
scene.setRenderParameter('ENGINE', b'RS0')
with that "b" before the text string.

Re: Pymaxwell and python 3.5

Posted: Tue Oct 10, 2017 8:48 pm
by seghier
Many thanks Brany
I will try it

Re: Pymaxwell and python 3.5

Posted: Tue Oct 10, 2017 9:37 pm
by seghier
thanks again ; it work fine :)
the error message disappear and there is a new one, i fix it by change MAXWELL3_ROOT to MAXWELL4_ROOT.
this __init__.py is : pymaxwell4.py from : "C:\Program Files\Next Limit\Maxwell Render 4\python\pymaxwell4\python3.5"
MAXWELL3_ROOT environment variable not found!
Traceback (most recent call last):
File "maxwell_toolv6.py", line 847, in render
self.rendering()
File "maxwell_toolv6.py", line 1003, in rendering
runMaxwell(parameters)
File "C:\Python35\lib\site-packages\pymaxwell\__init__.py", line 127, in runMaxwell
parameters.insert(0,mwroot+'/maxwell.exe');
UnboundLocalError: local variable 'mwroot' referenced before assignment