Everything related to SDK.
User avatar
By seghier
#395406
hello
i tried to render animation with this code but i got error
Code: Select all
    def renderAnimation(self):
        inPath = self.anim_input.text().toAscii().data()
        mxsList = getFilesFromPath(inPath, 'mxs')

        scene = Cmaxwell(mwcallback)
        for mxs in mxsList:
            scene.readMXS(os.path.join(inPath, mxs))
            #ok = scene.writeMXS(os.path.join(outPath, mxs))
            #outPath = self.edit_input_file.text().toAscii().data()
            outMxi = self.edit_mxi_file.text().toAscii().data()
            #outMxs = self.edit_mxs_file.text().toAscii().data()
            outImg = self.edit_img_file.text().toAscii().data()
            #outDen = self.edit_den_file.text().toAscii().data()
            choice = os.path.join(inPath, mxs)
            
            parameters = []

            parameters.append('-mxs:' + choice);
            parameters.append('-nowait');
            parameters.append('-nogui');
            parameters.append('-o:' + outImg);
            parameters.append('-mxi:' + outMxi);
            #parameters.append('-denoisePath:' + outDen);
            #parameters.append('-denoiseStartSL:' + str(Di));
            #parameters.append('-denoiseAutoconfig:' + str(v));
            runMaxwell(parameters);
            return 1;
            #scene.freeScene()
error :
C:\Python27\python.exe F:/maxwell_tool_project/v3/maxwell_tool.py
MAXWELL3_ROOT environment variable not found!
Traceback (most recent call last):
File "F:/maxwell_tool_project/v3/maxwell_tool.py", line 385, in renderAnimation
runMaxwell(parameters);
File "C:\Python27\lib\site-packages\pymaxwell\__init__.py", line 127, in runMaxwell
parameters.insert(0,mwroot+'/maxwell.exe');
UnboundLocalError: local variable 'mwroot' referenced before assignment
User avatar
By Brany
#395411
You found another bug! pymaxwell module expects Maxwell 3 installed instead of Maxwell 4.

To workaround this, you can define your own "runMaxwell" function like this, is quite simple:

Code: Select all
def myRunMaxwell( parameters ):
	if sys.platform == 'win32' or sys.platform == 'linux2':
		try:
			mwroot = os.environ['MAXWELL4_ROOT'];
		except:
			print('MAXWELL4_ROOT environment variable not found!');

	if sys.platform == 'win32':
		parameters.insert(0,mwroot+'/maxwell.exe');
	elif sys.platform == 'linux2':
		parameters.insert(0,mwroot+'/maxwell');
	elif sys.platform == 'darwin':
		parameters.insert(0,'/Applications/Maxwell Render 4/maxwell.app/Contents/MacOS/maxwell');
	else:
		error;

	subprocess.call(parameters);
User avatar
By seghier
#395416
i change the code like that but nothing happened ; no error and no render
Code: Select all
    def renderAnimation(self):
        inPath = self.anim_input.text().toAscii().data()
        mxsList = getFilesFromPath(inPath, 'mxs')

        for mxs in mxsList:
            scene = Cmaxwell(mwcallback)
            scene.readMXS(mxs)
            #ok = scene.writeMXS(os.path.join(outPath, mxs))
            #outPath = self.edit_input_file.text().toAscii().data()
            outMxi = self.edit_mxi_file.text().toAscii().data()
            #outMxs = self.edit_mxs_file.text().toAscii().data()
            outImg = self.edit_img_file.text().toAscii().data()
            #outDen = self.edit_den_file.text().toAscii().data()
            choice = os.path.join(inPath, mxs)

            parameters = []

            parameters.append('-mxs:' + choice);
            parameters.append('-nowait');
            parameters.append('-nogui');
            parameters.append('-o:' + outImg);
            parameters.append('-mxi:' + outMxi);
            #parameters.append('-denoisePath:' + outDen);
            #parameters.append('-denoiseStartSL:' + str(Di));
            #parameters.append('-denoiseAutoconfig:' + str(v));
            self.myRunMaxwell;
            return 1;
            #scene.freeScene()


    def myRunMaxwell(parameters):
        if sys.platform == 'win32' or sys.platform == 'linux2':
            try:
                mwroot = os.environ['MAXWELL4_ROOT'];
            except:
                print('MAXWELL4_ROOT environment variable not found!');

        if sys.platform == 'win32':
            parameters.insert(0, mwroot + '/maxwell.exe');
        elif sys.platform == 'linux2':
            parameters.insert(0, mwroot + '/maxwell');
        elif sys.platform == 'darwin':
            parameters.insert(0, '/Applications/Maxwell Render 4/maxwell.app/Contents/MacOS/maxwell');
        else:
            error;

        subprocess.call(parameters);
User avatar
By Brany
#395418
seghier wrote:
Wed Sep 13, 2017 12:41 pm
i change the code like that but nothing happened ; no error and no render
Code: Select all
    def renderAnimation(self):
        inPath = self.anim_input.text().toAscii().data()
        mxsList = getFilesFromPath(inPath, 'mxs')

        for mxs in mxsList:
            scene = Cmaxwell(mwcallback)
            scene.readMXS(mxs)
            #ok = scene.writeMXS(os.path.join(outPath, mxs))
            #outPath = self.edit_input_file.text().toAscii().data()
            outMxi = self.edit_mxi_file.text().toAscii().data()
            #outMxs = self.edit_mxs_file.text().toAscii().data()
            outImg = self.edit_img_file.text().toAscii().data()
            #outDen = self.edit_den_file.text().toAscii().data()
            choice = os.path.join(inPath, mxs)

            parameters = []

            parameters.append('-mxs:' + choice);
            parameters.append('-nowait');
            parameters.append('-nogui');
            parameters.append('-o:' + outImg);
            parameters.append('-mxi:' + outMxi);
            #parameters.append('-denoisePath:' + outDen);
            #parameters.append('-denoiseStartSL:' + str(Di));
            #parameters.append('-denoiseAutoconfig:' + str(v));
            self.myRunMaxwell;
            return 1;
            #scene.freeScene()


    def myRunMaxwell(parameters):
        if sys.platform == 'win32' or sys.platform == 'linux2':
            try:
                mwroot = os.environ['MAXWELL4_ROOT'];
            except:
                print('MAXWELL4_ROOT environment variable not found!');

        if sys.platform == 'win32':
            parameters.insert(0, mwroot + '/maxwell.exe');
        elif sys.platform == 'linux2':
            parameters.insert(0, mwroot + '/maxwell');
        elif sys.platform == 'darwin':
            parameters.insert(0, '/Applications/Maxwell Render 4/maxwell.app/Contents/MacOS/maxwell');
        else:
            error;

        subprocess.call(parameters);

I detect some possible bugs:

Code: Select all
    def renderAnimation(self):

            ...
            
            self.myRunMaxwell(parameters); # this call must include the parameters as input
            
            ...


    def myRunMaxwell(self,parameters): # since you defined myRunMaxwell inside a class, you must have "self" as the first input parameter
User avatar
By seghier
#395419
this one give me error : self.myRunMaxwell(parameters)
Traceback (most recent call last):
File "F:/maxwell_tool_project/v3/maxwell_tool.py", line 385, in renderAnimation
self.myRunMaxwell(parameters);
TypeError: myRunMaxwell() takes exactly 1 argument (2 given)

the second : no error, no render
is the code right ?
the code of render cameras views work fine
Code: Select all
    def rendering2(self):
        if not self.errorMessage():
            return;
        scene = Cmaxwell(mwcallback);
        ok = scene.readMXS(self.edit_input_file.text().toAscii().data());
        cameraNames = scene.getCameraNames();
        sl_orig = int(scene.getRenderParameter('SAMPLING LEVEL')[0]);
        st_orig = int(scene.getRenderParameter('STOP TIME')[0] / 60);
        for name in cameraNames:
            outPath = self.edit_input_file.text().toAscii().data()
            outMxi = self.edit_mxi_file.text().toAscii().data()
            outMxs = self.edit_mxs_file.text().toAscii().data()
            outImg = self.edit_img_file.text().toAscii().data()
            outDen = self.edit_den_file.text().toAscii().data()
            if len(outMxs) == 0:
                choice = outMxs
            else:
                choice = outPath
            if len(outMxi) == 0:
                num = 1
            else:
                num = 0
            camera = scene.getCamera(name)
            x_orig = int(camera.getResolution()[0])
            y_orig = int(camera.getResolution()[1])
            camera.setResolution(x_orig, y_orig)
            camera.setActive()
            nn = self.apply_den_lst.currentIndex()
            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_orig)
            scene.setRenderParameter('STOP TIME', st_orig)
            scene.setRenderParameter('DO NOT SAVE MXI FILE', self.check_img.isChecked() and num)
            scene.setRenderParameter('DO NOT SAVE IMAGE FILE', self.check_mxi.isChecked() and 0)
            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)
            ii = self.apply_den_lst.currentIndex()
            SL = int(self.strt_sl.value())
            if ii == 0:  # Each SL
                Di = SL
            elif ii == 1:  # At end
                Di = 0
            v = int(self.auto_conf_lst.currentIndex())+1
            ok = scene.writeMXS(choice)

            parameters = []
            parameters.append('-mxs:' + choice);
            parameters.append('-nowait');
            parameters.append('-nogui');
            parameters.append('-o:' + outImg);
            parameters.append('-mxi:' + outMxi);
            parameters.append('-denoisePath:' + outDen);
            parameters.append('-denoiseStartSL:' + str(Di));
            parameters.append('-denoiseAutoconfig:' + str(v));
            runMaxwell(parameters)
User avatar
By seghier
#395420
i try again with pymaxwell ; the code read the scenes but without render
the render for single scene work without errors

Image
Code: Select all
from pymaxwell import *
import os

def myRunMaxwell(parameters):
        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); 

def run_maxwell_render(inPath,outFolder):

        mxsList = getFilesFromPath(inPath, 'mxs')

        for mxs in mxsList:
            scene = Cmaxwell(mwcallback)
            choice = os.path.join(inPath, mxs)
            scene.readMXS(choice)
            print choice

            #choice = ok = scene.writeMXS(os.path.join(outFolder, mxs))

            parameters = []

            parameters.append('-mxs:' + choice);
            parameters.append('-nowait');
            parameters.append('-nogui');
            parameters.append('-o:' + outFolder + 'a.jpg');
            parameters.append('-mxi:' + outFolder + 'a.mxi');
            parameters.append('-time:10');
            parameters.append('-sl:5');
            parameters.append('-res:300x200');
            #runMaxwell(parameters);
            myRunMaxwell;
        #return 1;
        scene.freeScene()

            


if __name__ == "__main__":
	inPath = 'c:/input/anim/'
	outFolder = 'c:/intest'
	run_maxwell_render(inPath,outFolder)
User avatar
By seghier
#395421
i don't know why the render don't work ; i reinsatll maxwell and remove all files in the folder but the problem still happened.
i tried again with single scene and i got this error inpycharm :
C:\Python27\python.exe F:/maxwell_tool_project/v3/maxwell_tool.py
Traceback (most recent call last):
File "F:/maxwell_tool_project/v3/maxwell_tool.py", line 296, in rendering2
runMaxwell(parameters)
File "C:\Python27\lib\site-packages\pymaxwell\__init__.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

-----------
and this error in pymaxwell :
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 135, in runMaxwell
subprocess.call(parameters);
File "C:\Program Files\Next Limit\Maxwell Render 4\python\python\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Program Files\Next Limit\Maxwell Render 4\python\python\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Program Files\Next Limit\Maxwell Render 4\python\python\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified


before worked fine in pymaxwell and pycharm
User avatar
By seghier
#395422
and again this error :
MAXWELL3_ROOT environment variable not found!
Traceback (most recent call last):
File "<string>", line 30, in <module>
File "<string>", line 24, 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
User avatar
By seghier
#395424
i don't understand ; the code worked before fine but now some definition don't work as before :
the mxi and img output rendered even they are unchecked !
Code: Select all
    def rendering(self):
        if not self.errorMessage():
            return;
        scene = Cmaxwell(mwcallback);
        ok = scene.readMXS(self.edit_input_file.text().toAscii().data());
        cameraNames = scene.getCameraNames();
        for name in cameraNames:
            outPath = self.edit_input_file.text().toAscii().data()
            outMxi = self.edit_mxi_file.text().toAscii().data()
            outMxs = self.edit_mxs_file.text().toAscii().data()
            outImg = self.edit_img_file.text().toAscii().data()
            outDen = self.edit_den_file.text().toAscii().data()
            if len(outMxi) == 0:
                num = 1
            else:
                num = 0
            camera = scene.getCamera(name)
            x = int(self.edit_width.value())
            y = int(self.edit_height.value())
            sl = int(self.edit_sl.value())
            st = int(self.edit_time.value())*60
            camera.setResolution(x, y)
            camera.setActive()
            nn = self.engine_choice.currentIndex()
            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_img.isChecked() and num)
            scene.setRenderParameter('DO NOT SAVE IMAGE FILE', self.check_mxi.isChecked() and 0)
            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)
            ii = self.apply_den_lst.currentIndex()
            SL = int(self.strt_sl.value())
            if ii == 0:  # Each SL
                Di = SL
            elif ii == 1:  # At end
                Di = 0
            v = int(self.auto_conf_lst.currentIndex())+1
            if len(outMxs) == 0:
                choice = outPath
            else:
                choice = outMxs
            ok = scene.writeMXS(choice)

            parameters = []
            parameters.append('-mxs:' + choice);
            parameters.append('-nowait');
            parameters.append('-nogui');
            parameters.append('-o:' + outImg);
            parameters.append('-mxi:' + outMxi);
            parameters.append('-denoisePath:' + outDen);
            parameters.append('-denoiseStartSL:' + str(Di));
            parameters.append('-denoiseAutoconfig:' + str(v));
            runMaxwell(parameters)
User avatar
By Brany
#395430
I think I didn't explained myself in my last post!

I comment between line codes:
Code: Select all
from pymaxwell import *
import os

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); 

def run_maxwell_render(inPath,outFolder):

        mxsList = getFilesFromPath(inPath, 'mxs')

        for mxs in mxsList:
            scene = Cmaxwell(mwcallback)
            choice = os.path.join(inPath, mxs)
            scene.readMXS(choice)
            print choice

            #choice = ok = scene.writeMXS(os.path.join(outFolder, mxs))

            parameters = []

            parameters.append('-mxs:' + choice);
            parameters.append('-nowait');
            parameters.append('-nogui');
            parameters.append('-o:' + outFolder + 'a.jpg');
            parameters.append('-mxi:' + outFolder + 'a.mxi');
            parameters.append('-time:10');
            parameters.append('-sl:5');
            parameters.append('-res:300x200');
            
            
            # this one calls the pymaxwell "runMaxwell", it only works for Maxwell 3 so forget it for now (it will be fixed in the next release)
            #runMaxwell(parameters);
            
            
            # this call is wrong, it will return the function memory address, so it won't fail and it won't do anything!
            # you must call it this way:   myRunMaxwell(parameters);
            myRunMaxwell;
            
            
        #return 1;
        scene.freeScene()

if __name__ == "__main__":
	inPath = 'c:/input/anim/'
	outFolder = 'c:/intest'
	run_maxwell_render(inPath,outFolder)

I'm working with Maya and when I place MXS referen[…]

Porcelain test with SSS

Never worked with Keyshot but that does look like […]

Renders my own stuff

thank you for the comments, i'm encouraged to do m[…]

Fernando, I believe in you to solve this problem ![…]