Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@evitolins
Created August 31, 2014 17:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evitolins/0a324c1392dbd25aaf32 to your computer and use it in GitHub Desktop.
Save evitolins/0a324c1392dbd25aaf32 to your computer and use it in GitHub Desktop.
Maya CommandPort methods to assist with MayaSublime package integration.
import maya.cmds as cmds
def activateCommandPort(host='127.0.0.1', port='7002', language="python"):
path = host + ":" + port
active = cmds.commandPort(path, q=True)
if not active:
cmds.commandPort(name=path, sourceType=language)
else:
print("%s is already active" % path)
def deactivateCommandPort(host, port):
path = host + ":" + port
active = cmds.commandPort(path, q=True)
if active:
cmds.commandPort(name=path, cl=True)
else:
print("%s is was not active" % path)
# Activate
activateCommandPort('127.0.0.1', '7001', 'mel')
activateCommandPort('127.0.0.1', '7002', 'python')
# Deactiviate
deactivateCommandPort('127.0.0.1', '7001')
deactivateCommandPort('127.0.0.1', '7002')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment