我想知道有没有办法通过python套接字和玛雅自己的“commandPort”命令向玛雅发送多行命令?
我正在使用以下代码将代码发送到 Maya(“消息”值是命令):
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()
引发“无效的语法错误”!