Page 5 of 5

Re: Pymaxwell and Tk (tkinter)

Posted: Tue Sep 26, 2017 1:52 pm
by seghier
i think i find why this problem happened; when open new scene the camera list must cleared and also the input mxs file .
the problem is must clear the input file and at the same time must open new file.
if the input file don't cleared the app crash
a temporary solution : add reset button to clear the camera list and the input file before choose a new scene

Re: Pymaxwell and Tk (tkinter)

Posted: Tue Sep 26, 2017 3:36 pm
by Brany
I don't see where is the problem. There is no console output error from Qt?

Maybe you can try to check if self.cameras is empty or not, and only call self.cameras.clear() when it is not empty.

Re: Pymaxwell and Tk (tkinter)

Posted: Tue Sep 26, 2017 6:50 pm
by seghier
i tried with self .cameras.count to check if it is empty or not but the problem is :

def open(self):
****
self.cameraList()
self.changeWH()
****
def camerasList(self):
*****
camera = scene.getCamera(name)
self.cameras.addItem(name)
*****

def changeWH(self):
*****
cameraName = self.cameras.currentText()
*****
when i open a scene open call the camera list and the resolution functions with cameras.clear; if i choose another scene when the camera list and the input scene field are not empty i got error with python.exe and the app closed.
i add a reset button with one function to clear the cameras list but the same problem happened again
if i don't use clear when open the scene the camera list got new items + the old items and one of them do the same crash.
i am still trying to find solution

Re: Pymaxwell and Tk (tkinter)

Posted: Tue Sep 26, 2017 8:24 pm
by seghier
i think the problem finally solved ; Thanks Brany for help :)
def open(self):
self.clearAll()
inPath = QtGui.QFileDialog.getOpenFileName(self, 'Open file', 'C:/', filter='*.mxs');
self.edit_input_file.setText(inPath);
input_mxs = self.edit_input_file.text()
filepath_mxs = os.path.splitext(input_mxs.toAscii().data())[0]
file_ext_mxs = os.path.splitext(input_mxs.toAscii().data())[1]
new_mxs = filepath_mxs + '_modified' + file_ext_mxs
if not len(input_mxs) == 0:
self.edit_mxs_file.setText(new_mxs)
self.camerasList()
self.changeWH()
self.original()

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 2:50 am
by seghier
what must change in the code to make it work with pymaxwell for maxwell V3?
some new features like denoiser must removed but what about other commands ?

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 12:08 pm
by Brany
Of course, you have to use pymaxwell python module from maxwell 3.x, otherwise the saved scenes won't be compatible with maxwell 3 (only with maxwell 4).

Also you cannot give the option to render with the GPU engine.

The number of threads has the range [0-maxThreads] in maxwell 3, but in maxwell 4 you can use negative numbers. E.g. -1 means that the render engine will use all threads but one.

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 1:39 pm
by seghier
Thank you .
I will try with it

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 5:26 pm
by seghier
it work fine ;
import sys
sys.path.append('C:\Program Files\Next Limit\Maxwell 3\python\pymaxwell\python2.7')
from pymaxwell import *
----
i tried with the version for pymaxwell 4
import sys
sys.path.append('C:\Program Files\Next Limit\Maxwell Render 4\python\python\lib\site-packages\pymaxwell')
from pymaxwell import *
or
import sys
sys.path.append('C:\Program Files\Next Limit\Maxwell Render 4\python\pymaxwell4\python2.7')
from pymaxwell import *
but with this version i got error : from pymaxwell import *
ImportError: No module named pymaxwell

-----------------------------------
after posting i add :'C:\Program Files\Next Limit\Maxwell Render 4\python\pymaxwell4\python2.7' to environments variables and change from pymaxwell to pyamxwell4 ;the app launched and i got other error.
if i use this with pymaxwell folder copied to python folder it wor fine
import sys
from pymaxwell import *
if i use this :
import sys
sys.path.append('C:\Program Files\Next Limit\Maxwell Render 4\python\pymaxwell4\python2.7')
from pymaxwell4 import *
the app launched but not the render with error:
Traceback (most recent call last):
File "F:/Maxwell tool/v5/maxwell_toolv5.py", line 403, in render
self.rendering()
File "F:/Maxwell tool/v5/maxwell_toolv5.py", line 516, in rendering
runMaxwell(parameters)
File "C:\Program Files\Next Limit\Maxwell Render 4\python\pymaxwell4\python2.7\pymaxwell4.py", line 135, in runMaxwell
subprocess.call(parameters);
File "C:\Python27\lib\subprocess.py", line 168, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 6:05 pm
by seghier
i add this from the other thread :
Code: Select all
    def MyrunMaxwell(parameters):
        # parameters is an input value, you MUST call myRunMaxwell(...) passing the "parameters" as input.
        if sys.platform == 'win32':
            try:
                mwroot = os.environ['MAXWELL4_ROOT'];
            except:
                print('MAXWELL4_ROOT environment variable not found!');

        if sys.platform == 'win32':
            parameters.insert(0, mwroot + '/maxwell.exe');

            error;

        subprocess.call(parameters);
and replace runMaxwell by selfMyrunMaxwell
the error disappear but the render don't launched

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 6:14 pm
by seghier
are the two pymaxwell4.pyd in maxwell folder different ?
when i change the folder to this:
C:\Program Files\Next Limit\Maxwell Render 4\python\python\lib\site-packages\pymaxwell
the problem solved

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 7:04 pm
by Brany
Since they are different packages (pymaxwell for maxwell 3 and maxwell 4) we named them differently:

pymaxwell (maxwell 3)
pymaxwell4 (maxwell 4)

so they can "live" in the same folder (e.g python/lib/site-packages/) and do from the same python script the following:
Code: Select all
import pymaxwell as mw3
import pymaxwell4 as mw4
...
The main source of confusion, is that the pymaxwell package for maxwell 4, for the pymaxwell editor (the pymaxwell editor's pymaxwell package is the same than the regular pymaxwell package, but copied in other place), is named "pymaxwell" instead of "pymaxwell 4" by mistake. That is a bug in the pymaxwell editor (pymaxwell.exe) and it will be solved in maxwell 4.2

Re: Pymaxwell and Tk (tkinter)

Posted: Wed Sep 27, 2017 9:05 pm
by seghier
Thanks Brany
The problem with importing the two pymaxwell modules for maxwell 3 and 4 is that the script don't detect both versions of maxwell .
When i install v3 even i used pymaxwell4 only the script always find v3 and show error about denoiser and than that the mxs file is created with higher versions.
How the script know which version will used to read, open , save and render ?
Using mw3/mw4 can solve this problem ?
If yes is it possible to use something to replace mw.
If mw3 replace mw by mw3 (or mw4)

Re: Pymaxwell and Tk (tkinter)

Posted: Thu Sep 28, 2017 10:42 am
by Brany
If you want your tool to be compatible with both maxwell 3 and maxwell 4, supporting the new features that maxwell 4 have, you have 2 options:

1) Generate 2 versions of the tool, one for maxwell 3 (using pymaxwell), and another one for maxwell 4 (using pymaxwell4). This is the easy approach, but you have to duplicate part of your code.

2) Have one single tool, but having an option to select which version of maxwell does the user want to use, Maxwell 3 or Maxwell 4. This option is more complicated than the 1st one because you have to do things like this in your code:
Code: Select all
import pymaxwell as mw3
import pymaxwell4 as mw4


...


def open_scene(path):
  if maxwell_version_selected == 3:
    scene = mw3.Cmaxwell(mw3.mwcallback)
  else if maxwell_version_selected == 4:
    scene = mw4.Cmaxwell(mw4.mwcallback)
  else:
    print('Error: wrong maxwell version selected')
    return None
  ....
  return scene
Besides, in that case you can disable one or another version in your scripts by checkin which version(s) of maxwell are installed:
Code: Select all
import os
...
mw3dir = os.environ['MAXWELL3_ROOT']
mw4dir = os.environ['MAXWELL4_ROOT']

...

maxwell_3_option_selectable = False
maxwell_4_option_selectable = False

if os.path.isdir(mw3dir):
  print('Maxwell 3 installed')
  maxwell_3_option_selectable = True


if os.path.isdir(mw4dir):
  print('Maxwell 4 installed')
  maxwell_4_option_selectable = True

Re: Pymaxwell and Tk (tkinter)

Posted: Thu Sep 28, 2017 11:02 am
by seghier
thank you Brany
i prefer two versions to avoid errors and i wait for Maxwell 4.2