Search code examples
pythonscriptingmaya

Maya: Python: How to open arnoldRenderView in the script editor


I am stuck on the Arnold's Python command list. For this current exercise, I need to make a light-painter (e.g. https://evermotion.org/articles/show/8837/light-painter-1-0) in Maya.

I need to make it so that the ArnoldRenderView opens up automatically. I have been searching for this quite a while now. All I have been able to find is this: "from mtoa.cmds.arnoldRenderView import arnoldRenderView".

Where can I find what flags I can use to make the ArnoldRenderView open up (by a button click)?

Or is there a more simple way to open up the ArnoldRenderView without accessing the "mtoa.cmds.arnoldRenderView"?

With Kind Regards, Rik.

EDIT: I have found two helpfull links with scripting in maya (Python) for arnold: https://arnoldsupport.com/2015/03/04/arnold-getting-started-with-the-arnold-python-api/ and https://trac.solidangle.com/arnoldpedia/chrome/site/Arnold-4.1.3.3/doc/api/index.html


Solution

  • I've found the answer to my problem.

    # import libraries (Maya Commands Library and mtoa Core Library)
    import maya.cmds as cmds
    import mtoa.core as core
    

    Like haggi krey said, you'll find the necessary functions in the arnoldmenu.py file

    #Copy paste both functions from the arnoldmenu.py Script (filepath: "C:\solidangle\mtoadeploy\2018\scripts\mtoa\ui\arnoldmenu.py")
    def arnoldOpenMtoARenderView():
        core.createOptions()
        cmds.arnoldRenderView(mode ="open")
    
    def arnoldMtoARenderView():
        # core.ACTIVE_CAMERA is not set, anything we could do here ?
        #if core.ACTIVE_CAMERA != None:
        #    cmds.arnoldRenderView(cam=core.ACTIVE_CAMERA)
        # so instead we're calling it without any argument
        core.createOptions()
        cmds.arnoldRenderView()
    
    #execute both functions
    arnoldOpenMtoARenderView()
    arnoldMtoARenderView()
    

    This script opens up the arnoldRenderView in same state as you last closed it.