首页 > 解决方案 > Maya:Python:如何在脚本编辑器中打开 arnoldRenderView

问题描述

我被困在 Arnold 的 Python 命令列表中。对于当前的练习,我需要在 Maya中制作一个光绘器(例如https://evermotion.org/articles/show/8837/light-painter-1-0 )。

我需要让 ArnoldRenderView 自动打开。我一直在寻找这个很长一段时间了。我所能找到的只是:“ from mtoa.cmds.arnoldRenderView import arnoldRenderView”。

在哪里可以找到可以用来打开 ArnoldRenderView(通过单击按钮)的标志?

或者有没有更简单的方法来打开 ArnoldRenderView 而无需访问“ mtoa.cmds.arnoldRenderView”?

亲切的问候,瑞克。

编辑: 我发现了两个有用的关于 Arnold 在 Maya (Python) 中编写脚本的链接: https ://arnoldsupport.com/2015/03/04/arnold-getting-started-with-the-arnold-python-api/ 和https ://trac.solidangle.com/arnoldpedia/chrome/site/Arnold-4.1.3.3/doc/api/index.html

标签: pythonscriptingmaya

解决方案


我找到了我的问题的答案。

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

就像 haggi krey 说的,你会在arnoldmenu.py文件中找到必要的函数

#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()

此脚本以与您上次关闭时相同的状态打开 arnoldRenderView。


推荐阅读