我正在尝试创建一个简单的Python脚本,它将从Maya内部调用一个MEL脚本来创建一个多维数据集。耶!应该是相当直截了当的,尽管我可能把源文件的语法搞错了。
我现在拥有的是:
runMEL.py Python文件:将maya.mel导入为mel
def runMEL():
print ("Running MEL from Python!")
mel.eval('"source D:\Maya_Python\myMELScript.mel;"') # source of the file
mel.eval("myMELScript;") #name of the function
runMEL() # call the function above和MEL脚本myMELScript.mel
global proc myMELScript()
// call a MEL script with Python
{
polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1;
print("MEL just made a cube!");
}我从控制台得到以下信息:
Running MEL from Python!
// Error: "source D:\Maya_Python\myMELScript.mel;"; //
// Error: Line 1.40: Syntax error //
# Error: RuntimeError: file <maya console> line 5: Error occurred during execution of MEL script
Line 1.40: Syntax error #发布于 2017-12-13 10:08:28
你几乎把它做对了,你必须以字符串的形式传递路径,然后转义它。此外,mel对前向的/和向后的\斜线很挑剔,它期望/
这应该可以做到:
mel.eval('source "D:/Maya_Python/myMELScript.mel"')注意事项:通常在python中,您可以编写路径以及
D:\\Maya_Python\\myMELScript.mel但是梅尔不够聪明,所以它会转义符号:D。
https://stackoverflow.com/questions/47790125
复制相似问题