我想知道有没有办法通过python套接字和Maya自己的“commandPort”命令向maya发送多行命令?
我使用下面的代码将代码发送到 Maya(“message”值是命令):
import socket
#HOST = '192.168.1.122' # The remote host
HOST = '127.0.0.1' # the local host
PORT = 54321 # The same port as used by the server
ADDR=(HOST,PORT)
def SendCommand():
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(ADDR)
command = 'import maya.cmds as mc mc.polyCube()' # the commang from external editor to maya
MyMessage = command
client.send(MyMessage)
data = client.recv(1024) #receive the result info
client.close()
print 'The Result is %s'%data
if __name__=='__main__':
SendCommand()
当我发送像“polyCube()”这样的单个命令时,它可以工作,但例如发送一个 python
命令如:
import maya.cmds as mc
mc.polyCube()
引发“无效语法错误”!
Try:
command = 'import maya.cmds as mc\n mc.polyCube()'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)