我跟着http://www.toadstorm.com/blog/?p=136打开了一个没有用户界面的玛雅场景。
这是主要的脚本:
Assigned_To
这是要求的脚本:
import maya.cmds as cmds
import subprocess
# replace mayaPath with the path on your system to mayapy.exe
mayaPath = 'C:/Program Files/Autodesk/Maya2018/bin/mayapy.exe'
# replace scriptPath with the path to the script you just saved
scriptPath = 'C:/Users/Rik/Desktop/CreateNewLayerWithMeshesForBatchRenderPurpose.py'
def massAddRenderLayer(filenames, layername):
for filename in filenames:
maya = subprocess.Popen(mayaPath+' '+scriptPath+' '+filename+' '+layername,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out,err = maya.communicate()
exitcode = maya.returncode
if str(exitcode) != '0':
print(err)
print 'error opening file: %s' % (filename)
else:
print 'added new layer %s to %s' % (out,filename)
filenames = ['C:\Users\Rik\Desktop\Test_maya_file_FILE1.ma']
renderLayerToAdd = 'newRenderLayer'
massAddRenderLayer(filenames, renderLayerToAdd)
当我运行主脚本时,他打开了mayapy.exe程序,但是当我想渲染一个帧时,即使我导入了arnold并加载了' mtoa,我也会收到错误import sys
import maya.standalone as std
std.initialize(name='python')
import maya.cmds as cmds
from mtoa.cmds.arnoldRender import arnoldRender
filename = sys.argv[1]
layername = sys.argv[2]
def addRenderLayer(filename,layername):
try:
cmds.file(filename,o=True,f=True)
newLyr = cmds.createRenderLayer(n=layername,empty=True,makeCurrent=True)
meshes = cmds.ls(type='mesh')
xforms = []
for i in meshes:
xf = cmds.listRelatives(i,p=True)[0]
xforms.append(xf)
cmds.editRenderLayerMembers(layername,xforms)
cmds.loadPlugin( 'mtoa.mll' )
arnoldRender(1, 1, True, True,'camera1', ' -layer' + newLyr)
cmds.setAttr("defaultArnoldDriver.ai_translator", "png", type="string")
cmds.setAttr("defaultArnoldDriver.pre", "file_name", type="string")
arnoldRender(1920, 1080, True, True,'camera1', ' -layer' + newLyr)
sys.stdout.write(newLyr)
return newLyr
except Exception, e:
sys.stderr.write(str(e))
sys.exit(-1)
addRenderLayer(filename,layername)
.mll'插入。
我如何注册'阿诺德'?