你应该跑
system
Python脚本中的MEL命令。为此,您需要使用
mel.eval
eval
命令是为用户提供一种执行MEL命令或程序的方式,该命令或程序只能在运行时确定。
import maya.mel as mel
def RunNuke(self):
mel.eval('system "/Applications/Nuke10.5v5/Nuke10.5v5.app/Contents/MacOS/Nuke10.5v5 --nc --nukex"')
我在macOS(而不是Windows)上运行非商业版本的NUKEX,它可以工作。
代码的完整版本应如下所示:
from PySide import QtCore, QtGui
import maya.cmds as cmds
import os, sys
import maya.mel as mel
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(314, 216)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth( Dialog.sizePolicy().hasHeightForWidth() )
Dialog.setSizePolicy(sizePolicy)
self.blastBtn = QtGui.QPushButton(Dialog)
self.blastBtn.setGeometry(QtCore.QRect(110, 130, 75, 23))
self.blastBtn.setObjectName("blastBtn")
self.blastBtn.clicked.connect(self.RunPlayblast)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Playblast & Nuke Me", None, QtGui.QApplication.UnicodeUTF8))
self.blastBtn.setText(QtGui.QApplication.translate("Dialog", "Blast", None, QtGui.QApplication.UnicodeUTF8))
def RunPlayblast(self):
cmds.playblast(fmt="qt", f="myMovie.mov", fo=True)
self.RunNuke()
def RunNuke(self):
mel.eval('system "/Applications/Nuke10.5v5/Nuke10.5v5.app/Contents/MacOS/Nuke10.5v5 --nc --nukex "')
if __name__ == '__main__':
app = QtGui.QApplication.instance()
Dialog = QtGui.QDialog()
blastMe = Ui_Dialog()
blastMe.setupUi(Dialog)
Dialog.show()
app.exec_()
safe mode
:
import maya.mel as mel
def RunNuke(self):
mel.eval('system "C:\Program Files\Nuke9.0v8\Nuke9.0.exe" --safe --nc --nukex')
阅读:
Launching NUKE and HIERO in safe mode
如果它仍然不起作用,我认为这是Python库中的一个bug,或者是init内容中的一个问题。py。