几次测试后发现外部命令发送,对mel端口支持好,python老是无法接通。
# Maya 端运行脚本 scripts
import maya.cmds as cmds
# mel port
if not cmds.commandPort( ':7001', q = True ):
cmds.commandPort(n = ':7001', stp = 'mel')
cmds.warning('Mel port 7001 is open...')
else:
cmds.commandPort(n = ':7001', cl = 1)
cmds.warning('Mel port 7001 is close...')
# python port
if not cmds.commandPort(':7002', q = True):
cmds.commandPort(n = ':
# IDE 外部编辑器发送代码如下:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', 7001))
s.send('print "hello world";')
s.send('polyCube();')
s.send('python("import maya.cmds as cmds; cmds.sphere()");')