Last active
May 17, 2018 07:32
-
-
Save teionn/dd69543424d370d363b5c7cb2e9bf655 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import maya.mel | |
import maya.OpenMaya as OpenMaya | |
def connectPort_2_Atom(_port=7005,_mode="python"): | |
#open port with Atom port | |
exi_port=cmds.commandPort(":%s" % _port,q=True) | |
if(exi_port==1): | |
try: | |
cmds.commandPort(name=":%s" % _port, cl=True) | |
OpenMaya.MGlobal.displayInfo("%s port :%s close" % (_mode,_port)) | |
except: | |
OpenMaya.MGlobal.displayError("error:closed %s port :%s" % (_mode,_port)) | |
else: | |
try: | |
cmds.commandPort(name=":%s" % _port, sourceType=_mode) | |
lunch_path="atom.exe" | |
maya.mel.eval("system \"load "+lunch_path+"\";") | |
OpenMaya.MGlobal.displayInfo("%s port :%s open" % (_mode,_port)) | |
except : | |
OpenMaya.MGlobal.displayError("error:opend %s port :%s" % (_mode,_port)) | |
connectPort_2_Atom(_port=7005,_mode="python") | |
connectPort_2_Atom(_port=7006,_mode="mel") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment