def maya_commandPort_bind(self): if maya: url = '%s:%d' % self.url print "opening command port on url %s" % url sys.stdout.flush() if not m.commandPort(url,q=1): m.commandPort(n=url)
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)
def setup_zombie_port(): """ Create a command port for zombie pipeline tool """ # Read port from file ... use default on problem # ------------------------------------------------------------------------------------- config_file = "N:\\PSL_GLOBALS\\PSL_Pipeline\\src\\tools\\zombie\\zombie\\config\\maya_commandport.cfg" try: import zombie.config.maya as maya_conf port = maya_conf.port print ("PSL_PIPELINE: Port from zombie config used.") except: print ("PSL_PIPELINE: Using default port") port = "10101" # Try to open the port # ------------------------------------------------------------------------------------- if cmds.commandPort(':%s' % str(port), q=True) !=1: try: cmds.commandPort(n=':%s' % str(port), eo = False, nr = False) except RuntimeError: print ("PSL_PIPELINE: CommandPort %s could not be opened. Possible that another maya instance occupies it?" % str(port)) else: print ("PSL_PIPELINE: CommandPort %s opened" % str(port)) else: print ("PSL_PIPELINE: CommandPort %s already opened" % str(port))
def MayaSP_open(): try: commandPort(name=':8080', sourceType='mel') print "port has successfully connected ", except: warning('port has already connected')
def stop(self): """ stop command port """ cmds.commandPort(name=self.cmdport_name, sourceType='python', close=True) self.status = cmds.commandPort(self.cmdport_name, query=True) print 'closing %s' % self.cmdport_name
def activateCommandPort(host, port, type): path = host + ":" + port active = cmds.commandPort(path, q=True) if not active: cmds.commandPort(name=path, sourceType=type) else: print("%s is already active" % path)
def MayaSublime_open(): try: commandPort(name=':7001', sourceType='mel') commandPort(name=':7002', sourceType='python') print "port has successfully connected ", except: warning('port has already connected')
def startrealtimeexp(*args): global recstart global recend numrow = cmds.scriptTable('scrtable', query=True, rows=True) if len(selectedBlend) > 0 and numrow > 1: if recstart == 0: recstart = 1 cmds.button('realtimecomm', edit=True, label='Stop Real Time Expression') #Start Comm cmds.commandPort(name="127.0.0.1:7777", echoOutput=False, noreturn=False, prefix="portData", returnNumCommands=True) cmds.commandPort(name=":7777", echoOutput=False, noreturn=False, prefix="portData", returnNumCommands=True) else: recstart = 0 cmds.button('realtimecomm', edit=True, label='Start Real Time Expression') #Stop Comm deactivateCommandPort('127.0.0.1', '7777')
def openPort(port): try: cmds.commandPort(n=':'+str(port), sourceType='python') SETTINGS.add('mayaDmptoolsCommandPort', port) print 'opening port', port, 'for incoming dmptools commands...' return True except: return False
def stop(self): """Stops the maya command port for the host/port specified """ cmds.commandPort(name=self.cmdport_name, sourceType='python', close=True) self.status = cmds.commandPort(self.cmdport_name, query=True) print 'closing %s' % self.cmdport_name
def registerArnoldRenderer(): try: alreadyRegistered = pm.renderer('arnold', exists=True) if not alreadyRegistered: pm.evalDeferred(_register) # AE Templates # the following must occur even in batch mode because they contain calls to registerDefaultTranslator pm.evalDeferred(aeUtils.loadAETemplates) import rendererCallbacks rendererCallbacks.registerCallbacks() import mtoa.ui.ae.customShapeAttributes import mtoa.ui.ae.customShaderTemplates if not pm.about(batch=True): # Reload the AE Window if it has already been opened pm.evalDeferred(aeUtils.rebuildAE) # create the Arnold menu createArnoldMenu() # version specific overrides or additions _overridePythonScripts() _overrideMelScripts() # Add option box for file translator utils.pyToMelProc(exportass.arnoldAssOpts, [('string', 'parent'), ('string', 'action'), ('string', 'initialSettings'), ('string', 'resultCallback')], useName=True) # callbacks import mtoa.core as core core.installCallbacks() core.MTOA_GLOBALS['COMMAND_PORT'] = None import maya.cmds as cmds if not pm.about(batch=True): commandPortBase = 4700 try: commandPortBase = int(os.environ['MTOA_COMMAND_PORT']) except: commandPortBase = 4700 # opening a command port for different tools and maya batch progress messages for port in range(commandPortBase, commandPortBase + 100): commandPortName = ':%i' % port try: cmds.commandPort(name=commandPortName) core.MTOA_GLOBALS['COMMAND_PORT'] = port break except: pass if not pm.about(batch=True): pm.evalDeferred(arnoldShelf.createArnoldShelf) except: import traceback traceback.print_exc(file=sys.__stderr__) raise
def portOpen(self, mode, langue, port= None): self._setDomain(mode) self._setPortal(port) ipaddr = '%s:%d' % (self.host, self.port) cmds.commandPort(n= ipaddr, stp= langue, eo= 0, bs= self.buff) self.maps[str(self.port)] = {'ipaddr' : ipaddr, 'langue' : langue, 'status' : True} return ipaddr
def portClose(self, port): if port == 0: for p in self.maps: if self.maps[p]['status']: self.portClose(p) return None ipaddr = self.maps[str(port)]['ipaddr'] self.maps[str(port)]['status'] = False cmds.commandPort(n= ipaddr, cl= 1)
def start_up(): print 'I will do everything for you %s and I am from %s' % (__name__, __file__) sys.path.append('D:\dave\pythonWorkSpace\ARC\CORE') sys.path.append('D:\dave\git\CIGDave\CIGDave\CIGScripts') sysPath() if cmds.commandPort(':7720', q=1) != 1: cmds.commandPort(n=':7720', eo=0, nr=1) print 'I have connected eclips'
def deleteSingleton(): if hasattr(__main__, CommandPort._singletonName): print 'SINGLETON DELETED!' commandPortObj = getattr(__main__, CommandPort._singletonName) MC.commandPort(name=':' + str(commandPortObj.portId()), close=True) CommandPort.microSleep() delattr(__main__, CommandPort._singletonName)
def setBridge(): ''' You can edit the userSetup.py the set auto bridge, Add the flow lines to userSetup.py. import maya.cmds as mc mc.commandPort(n = "localhost:18810", stp = "python") ''' mc.commandPort(n = "localhost:18810", stp = "python")
def close_port(): if _LAST_OPENED_PORT: portStr = ':{}'.format(_LAST_OPENED_PORT) if cmds.commandPort(portStr, q=True): cmds.commandPort(cl=True, name=portStr) print("Zlm port '{}' closed.".format(_LAST_OPENED_PORT)) else: print("Zlm port '{}' already closed".format(_LAST_OPENED_PORT))
def open_deadline_port(): cmds.commandPort(name=":{}".format(os.environ["MAYASEQUENCE_RENDER_PORT"]), sourceType="python") print("Deadline port is open.") # Reply to Deadline server waiting on Maya boot. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = ("localhost", int(os.environ["MAYASEQUENCE_LAUNCH_PORT"])) sock.connect(server_address)
def create(self): """ create a socket server in maya """ localIP = socket.gethostbyname(socket.gethostname()) pid = os.getgid() try: cmds.commandPort(n = "%s:%s"%(localIP, pid), cl = True) except RuntimeError: pass cmds.commandPort(n = "%s:%s"%(localIP, pid), stp = "python", eo = True)
def closePort(port): ''' Close a commandPort opened on the given port ''' _portLock.acquire() cmds.commandPort(name=':%d' % port, close=True) if port in _commandPorts: _commandPorts.remove(port) _portLock.release() print 'Closed command port on %d' % port
def MayaSublime_close(): try: commandPort(name=':7001', close=True) print "port:7001 has successfully disconnected ", except: warning('Could not close port 7001 (maybe it is not opened yet)') try: commandPort(name=':7002', close=True) print "port:7002 has successfully disconnected ", except: warning('Could not close port 7002 (maybe it is not opened yet)')
def _Command_Port_button__command(state=None): """ Opens the command port. :param state: Button state. :type state: bool """ try: cmds.commandPort(name="127.0.0.1:" + str(cmds.intSliderGrp("Command_Port_intSliderGrp", query=True, value=True))) except: mel.eval("warning(\"sIBL_GUI | Command port is already open or can't be opened!\");") _setCommandPortOptionVar()
def open_port(): # Open the commandPort. # The 'prefix' argument string is calling to the defined # mel script above (which then calls to our Python function # of the same name): cmds.commandPort(name=host_adress, echoOutput=False, noreturn=False, prefix=proc_name, returnNumCommands=True) cmds.commandPort(name=port_id, echoOutput=False, noreturn=False, prefix=proc_name, returnNumCommands=True)
def start(self): """ starts a command port""" # check network info utils.validate_host(self.host) utils.validate_port(self.port) self.cmdport_name = "%s:%s" % (self.host, self.port) self.status = cmds.commandPort(self.cmdport_name, query=True) # if down, start a new command port if self.status is False: cmds.commandPort(name=self.cmdport_name, sourceType='python') self.status = cmds.commandPort(self.cmdport_name, query=True) print 'listening %s' % self.cmdport_name
def open_port(): global _LAST_OPENED_PORT settings = ZlmSettings() port = settings.get_app_port('Maya') portStr = ':{}'.format(port) if _LAST_OPENED_PORT != port: close_port() if not cmds.commandPort(portStr, q=True): cmds.commandPort(name=portStr, sourceType='python', noreturn=True) _LAST_OPENED_PORT = port print("Zlm port '{}' opened.".format(port)) else: print("Zlm port '{}' already opened.".format(port))
def main(): try: try: import maya.cmds as cmds import maya.utils if not cmds.commandPort(':{}'.format(PORT), q=1): cmds.commandPort(n=':{}'.format(PORT)) # maya.utils.executeDeferred(cmds.commandPort(n=':{}'.format(PORT))) print(cmds.commandPort(':{}'.format(PORT), q=1)) except ImportError: import hou, hrpyc hrpyc.start_server(PORT, False, False) pydevd.stoptrace() pydevd.settrace("localhost", port=PORT - 1, stdoutToServer=True, stderrToServer=True) print("trace start") except: pydevd.stoptrace() cmds.commandPort(n=':{}'.format(PORT), close=1) print("trace stop", "maya port {}".format(cmds.commandPort(':{}'.format(PORT), q=1)))
def __createCommandPort(): ip = socket.gethostbyname(socket.gethostname()) port = 6000 addr = '%s:%s' % (ip, port) # Close ports if they were already open under another configuration try: mc.commandPort(n=addr, close=True) except: mc.warning('Could not close port %s (maybe it is not opened yet...)' % port) mc.commandPort(n=addr, sourceType='python') port = mc.commandPort(addr, q=True) if port: print '\n\tCommandPort %s Opened!\n' % addr else: print '\n\tCommandPort %s Closed!\n' % addr
def _Command_Port_button__command(state=None): """ Opens the command port. :param state: Button state. :type state: bool """ try: cmds.commandPort(name="127.0.0.1:" + str( cmds.intSliderGrp( "Command_Port_intSliderGrp", query=True, value=True))) except: mel.eval( "warning(\"sIBL_GUI | Command port is already open or can't be opened!\");" ) _setCommandPortOptionVar()
def doIt(self, args): try: cmds.commandPort(name=":7001", close=True) except: cmds.warning('Could not close port 7001 (maybe it is not opened yet...)') try: cmds.commandPort(name=":7002", close=True) except: cmds.warning('Could not close port 7002 (maybe it is not opened yet...)') cmds.commandPort(name=":7001", sourceType="mel") cmds.commandPort(name=":7002", sourceType="python")
def doIt(self, args): try: cmds.commandPort(name=":7001", close=True) except: cmds.warning( 'Could not close port 7001 (maybe it is not opened yet...)') try: cmds.commandPort(name=":7002", close=True) except: cmds.warning( 'Could not close port 7002 (maybe it is not opened yet...)') cmds.commandPort(name=":7001", sourceType="mel") cmds.commandPort(name=":7002", sourceType="python")
def _openPort(self, portId=None, callback=None): singleton = getattr(__main__, CommandPort._singletonName) # The string in _singletonName is a __main__-name and Python called by MEL lives # in the interpreter namespace/module __main__; hence what follows is legal: ''' global proc _commandPort_melCallback(string $arg){ python("commandPortSingleton._messageReceived(\"" + $arg + "\")"); } ''' melCallbackWrapper = """ global proc _commandPort_melCallback(string $arg){{ python("{0}(\\"" + $arg + "\\")"); }} """.format(CommandPort._singletonName + '._messageReceived') MM.eval(melCallbackWrapper) """ NO, THE CALLBACK IS NOW DYNAMIC """ # If the port is already present, close it and rebuild; otherwise the callback won't change! portIdString = ':' + str(portId) if MC.commandPort(portIdString, query=True): MC.commandPort(name=portIdString, close=True) CommandPort.microSleep() print 'commandPort ' + str(portIdString) + 'closed!' MC.commandPort(name=portIdString, prefix='_commandPort_melCallback', echoOutput=False, noreturn=False, returnNumCommands=False) CommandPort.microSleep() print 'PORT OPEN!' self._portId = portId
def _openPort(self, portId, portName, callback): instance = CommandPort._instance # Python called by MEL lives in the interpreter namespace/module __main__; but we # can get a name to this class by using an import (to get a new name binding): ''' global proc _commandPort_melCallback(string $arg){ python("import MuTools.MuMessaging; commandPortSingleton._messageReceived(\"" + $arg + "\")"); } ''' melCallbackWrapper = """ global proc _commandPort_melCallback(string $arg){{ python("{0}(\\"" + $arg + "\\")"); }} """.format(CommandPort._singletonName + '._messageReceived') MM.eval(melCallbackWrapper) """ NO, THE CALLBACK IS NOW DYNAMIC """ # If the port is already present, close it and rebuild; otherwise the callback won't change! portIdString = ':' + str(portId) if MC.commandPort(portIdString, query=True): MC.commandPort(name=portIdString, close=True) CommandPort.microSleep() print 'commandPort ' + str(portIdString) + 'closed!' MC.commandPort(name=portIdString, prefix='_commandPort_melCallback', echoOutput=False, noreturn=False, returnNumCommands=False) CommandPort.microSleep() print 'PORT OPEN!' self._portId = portId
def __init__(self): super(InitUserSetup, self).__init__() # First greeting to user self.greetings() self.makePipelineMenu() # Create port for Vray material presets pro try: cmds.commandPort(n="localhost:7088") except RuntimeError: logger.debug('port:7088 already activated') else: pass # Load pipeline tool custom layout self.loadLayout() # Load pipeline tool UI dockable self.mayaMainUI() # Load timeline color marker script self.loadTimelineColorMarker()
def __init__(self): super(InitUserSetup, self).__init__() # First greeting to user self.greetings() var.createLog('maya') SCR = os.path.join( SCRPTH, NAMES['os'][0] ) if os.path.exists( SCR ): logger.info( 'Start updateing sys path' ) self.updatePathFromUser(SCR) else: self.adviceToInstallAnanconda() # Create menu in Maya Layout self.makePipelineMenu() # Create port for Vray material presets pro cmds.commandPort(n='localhost:7088') # Load pipeline tool UI dockable self.mayaMainUI() # Load pipeline tool custom layout self.loadLayout()
def mayaSublimePort(): # if it was already open under another configuration cmds.commandPort(name=":7002", close=True) # now open a new port cmds.commandPort(name=":7002", sourceType="python") # or open some random MEL port (make sure you change it to this port in your config file) cmds.commandPort(name=":10000", sourceType="mel")
def customOCTV(): UserName = os.environ['COMPUTERNAME'] if UserName: if UserName[:4].upper() == 'PCGR' or UserName[:6].upper() == 'RENDER': #加载项目到Script sys.path.append(r'\\octvision.com\cg\Tech\maya\2013\Lib') try: from PyQt4 import QtCore, QtGui import maya.OpenMayaUI as mui import sip except: pass import OCT_about import OCT_anim import OCT_cam import OCT_generel import OCT_lgt import OCT_render import OCT_menu import OCT_mod import OCT_util import OCT_vfx try: projectsSearch() except: pass #载入开启maya的触发事件 CommonSceneOpened() if not mc.about(batch=True): OCTVSceneOpenedScriptJob() try: OCT_menu.makeMenu() except: om.MGlobal.displayError(u'加载界面时出现异常2,请联系管理员.') #加载PYQT #设置通信端口 if not mc.commandPort('0.0.0.0:8321', q=True): mc.commandPort(n='0.0.0.0:8321', stp='python', eo=True) if not mc.commandPort('0.0.0.0:8322', q=True): mc.commandPort(n='0.0.0.0:8322', stp='mel', eo=True) # mm.eval('putenv "MAYA_SCRIPT_PATH" "MAYA_TESTING_CLEANUP";') else: del OCT_about del OCT_anim del OCT_cam del OCT_generel del OCT_lgt del OCT_render del OCT_menu del OCT_mod del OCT_util del OCT_vfx sys.path.remove(r'\\octvision.com\cg\Tech\maya\2013') om.MGlobal.displayError(u'OCT工具初始化时出现异常,请联系管理员.')
def disconnect(): if (cmds.commandPort(':7001',q=True)): cmds.commandPort(name=":7001",cl=True) print 'disconnecting ":7001"' else: print 'port ":7001" allready disconnected' if (cmds.commandPort(':7002',q=True)): cmds.commandPort(name=":7002",cl=True) print 'disconnecting ":7002"' else : print 'port ":7002" allready disconnected'
def disconnect(): if (cmds.commandPort(':7001', q=True)): cmds.commandPort(name=":7001", cl=True) print 'disconnecting ":7001"' else: print 'port ":7001" allready disconnected' if (cmds.commandPort(':7002', q=True)): cmds.commandPort(name=":7002", cl=True) print 'disconnecting ":7002"' else: print 'port ":7002" allready disconnected'
def connect(): if not cmds.commandPort(":7001", q=True): cmds.commandPort(name=":7001", sourceType="mel") print 'Command Port ":7001" activated' else: print 'Command Port ":7001" allready active' if not cmds.commandPort(":7002", q=True): cmds.commandPort(name=":7002", sourceType="python") print 'Command Port ":7002" activated' else: print 'Command Port ":7002" allready active'
def connect(): if not cmds.commandPort( ":7001", q = True ): cmds.commandPort(name=":7001", sourceType="mel") print 'Command Port ":7001" activated' else: print 'Command Port ":7001" allready active' if not cmds.commandPort( ":7002", q = True ): cmds.commandPort(name=":7002", sourceType="python") print 'Command Port ":7002" activated' else: print 'Command Port ":7002" allready active'
def start(): print("BW Scripts Starting") print("Opening Command Port") cmds.commandPort(name="0.0.0.0:4477", sourceType="python")
def MayaSP_close(): try: commandPort(name=':8080', close=True) print "port:8080 has successfully disconnected ", except: warning('Could not close port 8080 (maybe it is not opened yet)')
import maya.cmds as mc import maya.mel as mm melproc = """ global proc portData(string $arg){ python(("portData(\\"" + $arg + "\\")")); } """ mm.eval(melproc) def portData(arg): """ Read the 'serial' data passed in from the commandPort """ arg = arg.split(",") print "From Vicon: ", arg mc.setKeyframe('head', attribute='rotateX', t=float(arg[1]), v=float(arg[4])) mc.setKeyframe('head', attribute='rotateY', t=float(arg[1]), v=float(arg[5])) mc.setKeyframe('head', attribute='rotateZ', t=float(arg[1]), v=float(arg[6])) mc.setKeyframe('EyeL', attribute='rotateX', t=float(arg[1]), v=float(arg[11])) mc.setKeyframe('EyeL', attribute='rotateY', t=float(arg[1]), v=float(arg[12])) mc.setKeyframe('EyeR', attribute='rotateX', t=float(arg[1]), v=float(arg[15])) mc.setKeyframe('EyeR', attribute='rotateY', t=float(arg[1]), v=float(arg[16])) mc.commandPort(name="198.21.234.139:7777", echoOutput=False, noreturn=False, prefix="portData", returnNumCommands=True) mc.commandPort(name=":7777", echoOutput=False, noreturn=False, prefix="portData", returnNumCommands=True)
import maya.cmds as cmds # Close ports if they were already open under another configuration try: cmds.commandPort(name=":7001", close=True) except: cmds.warning('Could not close port 7001 (maybe it is not opened yet...)') try: cmds.commandPort(name=":7002", close=True) except: cmds.warning('Could not close port 7002 (maybe it is not opened yet...)') # Open new ports cmds.commandPort(name=":7001", sourceType="mel") cmds.commandPort(name=":7002", sourceType="python")
# coding:utf-8 # 用于 PyCharm 的 MayaCharm 插件 By Jason ([email protected]), 公众号: WendyAndAndy # 将这个文件放在:我的文档\maya\版本号\scripts 目录里 from maya import cmds if not cmds.commandPort(':4434', q=True): cmds.commandPort(n=':4434')
def customOCTV(): #检查机器名 UserName = os.environ['COMPUTERNAME'] if UserName: if UserName[:4].upper() == 'PCGR' or UserName[:2].upper( ) == 'SM' or UserName[:2].upper() == 'HW' or UserName[:6].upper( ) == 'TXXR' or UserName[:6].upper() == 'RENDER' or UserName[:6].upper( ) == 'render' or UserName[:3].upper() == 'WIN' or UserName[:6].upper( ) == 'YUNHAI' or UserName[:2].upper() == 'XR': #加载PYQT try: projectsSearch() except: pass #载入开启maya的触发事件 #修复物体材质 global OCTVSceneOpenedScriptJob mc.scriptJob(event=("SceneOpened", RepairShader)) #删除插件自动加载功能 mc.scriptJob(event=("SceneOpened", ClosePluginAutoload)) if not mc.about(batch=True): #启动检查磁盘大小的命令 global OCTVSceneOpenedScriptJob mc.scriptJob(event=("SceneOpened", CommonSceneOpened)) YetiSceneOpenedScriptJob() #加载PYQT try: import OCT_menu OCT_menu.makeMenu() except: om.MGlobal.displayError(u'加载界面时出现异常3,请联系管理员.') # try: # if not mc.pluginInfo('vrayformaya.mll', query=True, loaded=True): # mc.loadPlugin('vrayformaya.mll') # except: # om.MGlobal.displayError(u'Vray渲染器没有安装!请安装!') # try: # if not mc.pluginInfo('mtoa.mll', query=True, loaded=True): # mc.loadPlugin('mtoa.mll') # except: # om.MGlobal.displayError(u'Arnold渲染器加载失常,请联系管理员!') # try: # if not mc.pluginInfo('pgYetiMaya.mll', query=True, loaded=True): # mc.loadPlugin('pgYetiMaya.mll') # except: # om.MGlobal.displayError(u'Arnold渲染器加载失常,请联系管理员!') try: #设置通信端口 if not mc.commandPort('0.0.0.0:8321', q=True): mc.commandPort(n='0.0.0.0:8321', stp='python', eo=True) if not mc.commandPort('0.0.0.0:8322', q=True): mc.commandPort(n='0.0.0.0:8322', stp='mel', eo=True) except: pass else: del OCT_about del OCT_anim del OCT_cam del OCT_generel del OCT_lgt del OCT_render del OCT_menu del OCT_mod del OCT_util del OCT_vfx del OCT_check del OCT_vr del OCT_hair del OCT_matLib del OCT_proxy del OCT_animImEx del OCT_rigging del OCT_Projects sys.path.remove(r'\\octvision.com\cg\Tech\maya_sixteen') om.MGlobal.displayError(u'OCT工具初始化时出现异常,请联系管理员.')
import maya.cmds as cmds try: cmds.commandPort(name=":7001", sourceType='mel') cmds.commandPort(name=":7002", sourceType='python') except RuntimeError: pass if not cmds.optionVar(exists="firstLaunch"): # Force Auto load of plugins to False pluginList = cmds.pluginInfo(query=True, listPlugins=True) or [] for plugin in pluginList: cmds.pluginInfo(plugin, edit=True, autoload=False) cmds.undoInfo(state=True, infinity=True) cmds.optionVar(iv=("isIncrementalSaveEnabled", 1)) cmds.optionVar(iv=("RecentBackupsMaxSize", 10 )) cmds.optionVar(iv=("RecentFilesMaxSize", 10)) cmds.optionVar(iv=("RecentProjectsMaxSize", 10)) cmds.optionVar(iv=("displayViewportGradient", 1)) cmds.optionVar(iv=("loadDynamics", 0)) cmds.optionVar(iv=("loadUrchin", 0)) cmds.optionVar(iv=("maxTextureResolution", 1024)) cmds.optionVar(iv=("undoIsInfinite", 1)) cmds.optionVar(iv=("useSaveScenePanelConfig", 0)) cmds.optionVar(iv=("useScenePanelConfig", 0)) cmds.optionVar(iv=("displayNewFeatureHighlights", 0)) cmds.optionVar(iv=("firstLaunch", 1))
melproc = """ global proc portData(string $arg){ python(("portData(\\"" + $arg + "\\")")); } """ mm.eval(melproc) def portData(arg): """ Read the 'serial' data passed in from the commandPort """ print "Recieved!: ", arg # code that moves Left Arm Controller mappedVal=arg.split(",") mappedValx = float(mappedVal[0]) mappedValy = float(mappedVal[1]) print "mappedX:", mappedValx mappedValz = float(mappedVal[2]) if mc.objExists('Left_Arm_Controller'): mc.move(mappedValx, mappedValy, mappedValz) mc.commandPort(name="127.0.0.1:26232", echoOutput=False, noreturn=False, prefix="portData", returnNumCommands=True) mc.commandPort(name=":26232", echoOutput=False, noreturn=False, prefix="portData", returnNumCommands=True)
import dilloTools dilloTools.init() import maya.cmds as mc mc.commandPort(name=":7001",sourceType="mel") mc.commandPort(name=":7002",sourceType="python")
def connectToEclipse(): """Open a command port for Eclipse""" if not MC.commandPort(':7720', q=True): MC.commandPort(n=':7720', nr=True)
import maya.cmds as cmds if cmds.commandPort(':7720', q=True) !=1: cmds.commandPort(n=':7720', eo = False, nr = True)
def mGearLoader(): import mGear_menu mGear_menu.CreateMenu() utils.executeDeferred('mGearLoader()') # end mGear # start aTools if not cmds.about(batch=True): # launch aTools_Animation_Bar cmds.evalDeferred("from aTools.animTools.animBar import animBarUI; animBarUI.show('launch')", lowestPriority=True) # end aTools # cmds.evalDeferred('updateLineWidth 1.3;') # Open port for communication with Atom maya package cmds.commandPort(name=":7005", sourceType="python") # Open port for communication with Eclipse maya package cmds.commandPort(name=":7720", sourceType="python", eo=False, nr=True) """ import os, inspect USER_SETUP_PATH = os.path.dirname(inspect.currentframe().f_code.co_filename) """
def open_port(number): if not cmds.commandPort(':'+str(number), q=True): cmds.commandPort('mayaCommand', name=':'+str(number), sourceType='python')
def md_openCommandPort(port): name = "0.0.0.0:" + port cmds.commandPort(name=name, sourceType="python")
""" ## SCRIPT HEADER ## Created By : Muhammad Fredo Email : [email protected] Start Date : 04 Nov 2021 Info : """ import maya.cmds as cmds if not cmds.commandPort(':4434', query=True): print 'Connecting to PyCharm...' cmds.commandPort(name=':4434')
import maya.cmds as cmds if cmds.commandPort(':54321', q=True) !=1: cmds.commandPort(n=':54321', sourceType = 'python')