Re: [Maya-Python] Re: commandPort stack trace/errors
Have you looked at the code from my MayaSublime plugin for SublimeText? If I remember, it was one of these similar questions about talking to maya over a commandPort that prompted me to write the plugin as an example: https://github.com/justinfx/MayaSublime/blob/master/MayaSublime.py I don't handle reading back from the connection, but I do have it handling exceptions in the script editor On Mon, Jan 20, 2014 at 11:13 PM, James Morrison james_gegene_morri...@yahoo.com wrote: hi, just wondering if this was ever figured out. i got sublime sending commands..but when i try to do stuff like getAttr there's no feedback (# Result: ) that comes back...i'm looking around for an alternative to the charcoal editor...already have sublime so not looking to spend more $ on a new editor..:( cheers. On Thursday, September 20, 2012 6:54:47 PM UTC+9, Danny Wynne wrote: Im sending commands to maya from sublime text 2. How can I get the cmds.commandPort to print the stack trace and errors from those commands. cmds.commandPort(name=:7002, sourceType=python, eo=True, nr=True) i figured *echoOutput*(*eo*) and *noreturn*(*nr*) command arguments would do the trick, but it doesn't. thanks, -- You received this message because you are subscribed to the Google Groups Python Programming for Autodesk Maya group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9adcb65f-1653-4acb-83ed-b904189c8e98%40googlegroups.com . For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Python Programming for Autodesk Maya group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0ChyqGUD7--x7r_30g1MA3O3v_0gPb1hfwueR%2Bwi08jQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
[Maya-Python] Re: commandPort result size
For example i have 2 maya functions: 1. This return simple string Hello World 2. This return list of millions face indices With socket.recv how to know what size to read from result for best performance. I dont need to read millions of bytes to read result from function 1 in agressive looped scripts. I need fast solution. And also i want to ask you. Did you tried communicate with maya with rpc. To import maya modules into other python, like houdini does it with hrpyc. I want to find best solution to send cmds from other pythons -- You received this message because you are subscribed to the Google Groups Python Programming for Autodesk Maya group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To post to this group, send email to python_inside_maya@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [Maya-Python] Re: commandPort result size
I think you are misunderstanding how the recv method works. You do not have to know ahead of time exactly how many bytes are going to be returned to you. You just need to tell it how many bytes to try and read. You may get back less... import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((localhost, 12121)) s.sendall(cmds.ls()) ret = s.recv(4096) print len(ret) # 1305 Maya is not going to send you more than 4096 bytes for a response, otherwise that will be an error instead. So you have the option of reading the entire 4096 at once, or reading multiple times until you get back less than what you asked for... import cStringIO SIZE = 1024 EOF = '\x00' buf = cStringIO.StringIO() while True: data = s.recv(SIZE) if not data or data == EOF: break buf.write(data) if len(data) SIZE: break print buf.getvalue() But honestly, if the max buffer size of your commandPort is 4096, then its probably not that bad to just read all 4096 bytes right away, since you are most likely building a data structure out of the results anyways in memory. Unless of course you are writing the bytes to a file and you set your commandPort buffer to something huge for large return values. On Thu, Mar 14, 2013 at 3:36 PM, vux vuxs...@gmail.com wrote: For example i have 2 maya functions: 1. This return simple string Hello World 2. This return list of millions face indices With socket.recv how to know what size to read from result for best performance. I dont need to read millions of bytes to read result from function 1 in agressive looped scripts. I need fast solution. And also i want to ask you. Did you tried communicate with maya with rpc. To import maya modules into other python, like houdini does it with hrpyc. I want to find best solution to send cmds from other pythons -- You received this message because you are subscribed to the Google Groups Python Programming for Autodesk Maya group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To post to this group, send email to python_inside_maya@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Python Programming for Autodesk Maya group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To post to this group, send email to python_inside_maya@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[Maya-Python] Re: commandPort
I'd recommend you contact Wing support at this point, this sounds more related to your install my implementation. They're quite helpful. Good luck! On Feb 5, 7:26 pm, Subbu.Add subbu@gmail.com wrote: Dear Mr.Eric, I have got the module wingapi in the below path, C:\Program Files\Wing IDE 3.2\bin But still it is not getting imported. Which is the right place for modules in wing to get imported? By getting the content from wingapi, executed in wing. Even same problem with: import edit.editor import command.commandmgr Please help me. Subbu On Sat, Feb 6, 2010 at 8:25 AM, Subbu.Add subbu@gmail.com wrote: Thanks Mr. Eric. Now Am able to send text as command to Maya. So that from wing, with string assignment to txt variable, now it is possible to create sphere in Maya from wing. txt = 'sphere()' # in def send_to_maya(language) since 'getWingText()' is not working due to wingapi module is not avilable. It is showing error: ImportError: No module named wingapi Please help me how can I get wingapi module, since Am using wing ide professional trail version. ( whether this module is not supplied with trial version?) Subbu On Fri, Feb 5, 2010 at 10:43 PM, AK Eric warp...@sbcglobal.net wrote: Unless I'm missing something about your question, you can just copy- paste them from my wiki link above. The full source is right on that page. And if you're using Wing Pro, then yes, you can use that code per the wiki to have Wing talk to Maya. On Feb 4, 10:54 pm, Subbu.Add subbu@gmail.com wrote: Where can I get wingHotkeys.py and execPythonCode.py to use Wing IDE for sending commands to Maya. Presently Am using Wing IDE professional (30 day trail version). Whether this trial version can send commands from Wing to Maya. Subbu -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
Re: [Maya-Python] Re: commandPort
Dear Eric, Thank you for sharing the information what ever you know. Am really happy to see immediate replies from your end. Subbu On Sat, Feb 6, 2010 at 11:14 PM, AK Eric warp...@sbcglobal.net wrote: I'd recommend you contact Wing support at this point, this sounds more related to your install my implementation. They're quite helpful. Good luck! On Feb 5, 7:26 pm, Subbu.Add subbu@gmail.com wrote: Dear Mr.Eric, I have got the module wingapi in the below path, C:\Program Files\Wing IDE 3.2\bin But still it is not getting imported. Which is the right place for modules in wing to get imported? By getting the content from wingapi, executed in wing. Even same problem with: import edit.editor import command.commandmgr Please help me. Subbu On Sat, Feb 6, 2010 at 8:25 AM, Subbu.Add subbu@gmail.com wrote: Thanks Mr. Eric. Now Am able to send text as command to Maya. So that from wing, with string assignment to txt variable, now it is possible to create sphere in Maya from wing. txt = 'sphere()' # in def send_to_maya(language) since 'getWingText()' is not working due to wingapi module is not avilable. It is showing error: ImportError: No module named wingapi Please help me how can I get wingapi module, since Am using wing ide professional trail version. ( whether this module is not supplied with trial version?) Subbu On Fri, Feb 5, 2010 at 10:43 PM, AK Eric warp...@sbcglobal.net wrote: Unless I'm missing something about your question, you can just copy- paste them from my wiki link above. The full source is right on that page. And if you're using Wing Pro, then yes, you can use that code per the wiki to have Wing talk to Maya. On Feb 4, 10:54 pm, Subbu.Add subbu@gmail.com wrote: Where can I get wingHotkeys.py and execPythonCode.py to use Wing IDE for sending commands to Maya. Presently Am using Wing IDE professional (30 day trail version). Whether this trial version can send commands from Wing to Maya. Subbu -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
[Maya-Python] Re: commandPort
Unless I'm missing something about your question, you can just copy- paste them from my wiki link above. The full source is right on that page. And if you're using Wing Pro, then yes, you can use that code per the wiki to have Wing talk to Maya. On Feb 4, 10:54 pm, Subbu.Add subbu@gmail.com wrote: Where can I get wingHotkeys.py and execPythonCode.py to use Wing IDE for sending commands to Maya. Presently Am using Wing IDE professional (30 day trail version). Whether this trial version can send commands from Wing to Maya. Subbu -- http://groups.google.com/group/python_inside_maya
Re: [Maya-Python] Re: commandPort
Thanks Mr. Eric. Now Am able to send text as command to Maya. So that from wing, with string assignment to txt variable, now it is possible to create sphere in Maya from wing. txt = 'sphere()' # in def send_to_maya(language) since 'getWingText()' is not working due to wingapi module is not avilable. It is showing error: ImportError: No module named wingapi Please help me how can I get wingapi module, since Am using wing ide professional trail version. ( whether this module is not supplied with trial version?) Subbu On Fri, Feb 5, 2010 at 10:43 PM, AK Eric warp...@sbcglobal.net wrote: Unless I'm missing something about your question, you can just copy- paste them from my wiki link above. The full source is right on that page. And if you're using Wing Pro, then yes, you can use that code per the wiki to have Wing talk to Maya. On Feb 4, 10:54 pm, Subbu.Add subbu@gmail.com wrote: Where can I get wingHotkeys.py and execPythonCode.py to use Wing IDE for sending commands to Maya. Presently Am using Wing IDE professional (30 day trail version). Whether this trial version can send commands from Wing to Maya. Subbu -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
Re: [Maya-Python] Re: commandPort
Dear Mr.Eric, I have got the module wingapi in the below path, C:\Program Files\Wing IDE 3.2\bin But still it is not getting imported. Which is the right place for modules in wing to get imported? By getting the content from wingapi, executed in wing. Even same problem with: import edit.editor import command.commandmgr Please help me. Subbu On Sat, Feb 6, 2010 at 8:25 AM, Subbu.Add subbu@gmail.com wrote: Thanks Mr. Eric. Now Am able to send text as command to Maya. So that from wing, with string assignment to txt variable, now it is possible to create sphere in Maya from wing. txt = 'sphere()' # in def send_to_maya(language) since 'getWingText()' is not working due to wingapi module is not avilable. It is showing error: ImportError: No module named wingapi Please help me how can I get wingapi module, since Am using wing ide professional trail version. ( whether this module is not supplied with trial version?) Subbu On Fri, Feb 5, 2010 at 10:43 PM, AK Eric warp...@sbcglobal.net wrote: Unless I'm missing something about your question, you can just copy- paste them from my wiki link above. The full source is right on that page. And if you're using Wing Pro, then yes, you can use that code per the wiki to have Wing talk to Maya. On Feb 4, 10:54 pm, Subbu.Add subbu@gmail.com wrote: Where can I get wingHotkeys.py and execPythonCode.py to use Wing IDE for sending commands to Maya. Presently Am using Wing IDE professional (30 day trail version). Whether this trial version can send commands from Wing to Maya. Subbu -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
Re: [Maya-Python] Re: commandPort
Does this Wing IDE supports pymel also?? Subbu On Tue, Feb 2, 2010 at 10:30 PM, AK Eric warp...@sbcglobal.net wrote: Actually, I don't do any formatting when sending Python code from my IDE (Wing) to Maya. If anyone's interested I have the setup documented here: http://mayamel.tiddlyspot.com/#[[How%20can%20I%20have%20Wing%20send%20Python%20or%20mel%20code%20to%20Maya%3F]] (may have to copy-paste that link) Via that method, I can send both mel and python from the IDE, prettymuch letting me bypass the script editor entirely. But I agree: It's been nice to hear about the various solutions! ;) On Feb 2, 12:36 am, Shaun Friedberg sh...@pyrokinesis.co.nz wrote: Nice tips everyone! What I have been doing works fine for sending my Mel or Python scripts to Maya from my IDE. I thought it would be nice to remove the need to format my Python using Mel when sending it to Maya. My method is similar to AK Eric. Thanks again for all the input, definitely gives me some ideas to play with. -Original Message- From: python_inside_maya@googlegroups.com [mailto:python_inside_m...@googlegroups.com] On Behalf Of AK Eric Sent: Tuesday, February 02, 2010 12:18 PM To: python_inside_maya Subject: [Maya-Python] Re: commandPort Interesting, thanks for the tip, I'll give that a shot. I'm the first to admit I'm no socket expert ;) On Feb 1, 9:41 am, Marc Downie m...@openendedgroup.com wrote: As an aside: While you can open a socket with both mel and Python... I've found that no matter what I do, if I open a socket with Python, the above solution won't work.. I have to open it with mel. Frustrating. Well, at least on the mac I can state that this doesn't happen. We open sockets (port 1024) from Python all the time and they work like sockets. Are you sure you are getting the threadding right for executing the incoming python ? It seems to me that you have to use executeInMainThreadWithResult() [1] in order to have a socket server actually run code that it recieves. Marc [1] http://download.autodesk.com/us/maya/2009help/index.html?url=Python_P... --http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
Re: [Maya-Python] Re: commandPort
Where can I get wingHotkeys.py and execPythonCode.py to use Wing IDE for sending commands to Maya. Presently Am using Wing IDE professional (30 day trail version). Whether this trial version can send commands from Wing to Maya. Subbu -- http://groups.google.com/group/python_inside_maya
RE: [Maya-Python] Re: commandPort
Nice tips everyone! What I have been doing works fine for sending my Mel or Python scripts to Maya from my IDE. I thought it would be nice to remove the need to format my Python using Mel when sending it to Maya. My method is similar to AK Eric. Thanks again for all the input, definitely gives me some ideas to play with. -Original Message- From: python_inside_maya@googlegroups.com [mailto:python_inside_m...@googlegroups.com] On Behalf Of AK Eric Sent: Tuesday, February 02, 2010 12:18 PM To: python_inside_maya Subject: [Maya-Python] Re: commandPort Interesting, thanks for the tip, I'll give that a shot. I'm the first to admit I'm no socket expert ;) On Feb 1, 9:41 am, Marc Downie m...@openendedgroup.com wrote: As an aside: While you can open a socket with both mel and Python... I've found that no matter what I do, if I open a socket with Python, the above solution won't work.. I have to open it with mel. Frustrating. Well, at least on the mac I can state that this doesn't happen. We open sockets (port 1024) from Python all the time and they work like sockets. Are you sure you are getting the threadding right for executing the incoming python ? It seems to me that you have to use executeInMainThreadWithResult() [1] in order to have a socket server actually run code that it recieves. Marc [1]http://download.autodesk.com/us/maya/2009help/index.html?url=Python_P... -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
[Maya-Python] Re: commandPort
Actually, I don't do any formatting when sending Python code from my IDE (Wing) to Maya. If anyone's interested I have the setup documented here: http://mayamel.tiddlyspot.com/#[[How%20can%20I%20have%20Wing%20send%20Python%20or%20mel%20code%20to%20Maya%3F]] (may have to copy-paste that link) Via that method, I can send both mel and python from the IDE, prettymuch letting me bypass the script editor entirely. But I agree: It's been nice to hear about the various solutions! ;) On Feb 2, 12:36 am, Shaun Friedberg sh...@pyrokinesis.co.nz wrote: Nice tips everyone! What I have been doing works fine for sending my Mel or Python scripts to Maya from my IDE. I thought it would be nice to remove the need to format my Python using Mel when sending it to Maya. My method is similar to AK Eric. Thanks again for all the input, definitely gives me some ideas to play with. -Original Message- From: python_inside_maya@googlegroups.com [mailto:python_inside_m...@googlegroups.com] On Behalf Of AK Eric Sent: Tuesday, February 02, 2010 12:18 PM To: python_inside_maya Subject: [Maya-Python] Re: commandPort Interesting, thanks for the tip, I'll give that a shot. I'm the first to admit I'm no socket expert ;) On Feb 1, 9:41 am, Marc Downie m...@openendedgroup.com wrote: As an aside: While you can open a socket with both mel and Python... I've found that no matter what I do, if I open a socket with Python, the above solution won't work.. I have to open it with mel. Frustrating. Well, at least on the mac I can state that this doesn't happen. We open sockets (port 1024) from Python all the time and they work like sockets. Are you sure you are getting the threadding right for executing the incoming python ? It seems to me that you have to use executeInMainThreadWithResult() [1] in order to have a socket server actually run code that it recieves. Marc [1]http://download.autodesk.com/us/maya/2009help/index.html?url=Python_P... --http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
[Maya-Python] Re: commandPort
To my knowledge, Maya intercepts incoming commands as mel, irregardless of send methodology. You can send any type of data you want to Maya over the socket... but Maya will expect it to be mel when it receives it. I've not used MayaPad, but maybe it does something similar to what I do to work around this issue. Goes more or less like this: Open command port in Maya. In external app connect to that socket, save python code out as temp.py file. Ping Maya through command port to exec on temp.py. I do this via the API of my IDE: I can query what is hilighted, save that out as temp.py, and then have Maya execute it... lets me bypass the Maya script editor entirely. As an aside: While you can open a socket with both mel and Python... I've found that no matter what I do, if I open a socket with Python, the above solution won't work.. I have to open it with mel. Frustrating. On Feb 1, 6:27 am, Jo Jürgens jojurg...@gmail.com wrote: MayaPad does just that. Its a wxPython Python editor that can send commands to Maya. Maybe you can copy the way its done there http://code.google.com/p/mayapad/ On Mon, Feb 1, 2010 at 9:05 AM, Shaun Friedberg sh...@pyrokinesis.co.nzwrote: Right, perhaps I miss-spoke… I use Python to open a socket and then send Mel code. My question is does anyone know how to send Python code instead of Mel… -- http://groups.google.com/group/python_inside_maya
Re: [Maya-Python] Re: commandPort
Maya's command port is a special type of interface designed with the sole purpose of executing mel code. It is possible to use a generic python socket in Maya for whatever purpose you need. What comes through that socket is just data and Maya doesn't know anything about it. It would be your code that would decide how to handle it: store it, execute it if it's a command, etc. This approach is quite a bit more complex than simply opening the standard Maya command port, but it also offers a great deal of flexibility with nearly limitless potential. We use this method to communicate with our tool server. The tool server manages a lot of non-Maya specific data that is useful to our Maya tools: project locations, project settings, asset library data, etc. We pickle this data and send it from the tool server to Maya. From Maya we can make requests to the tool server as we need. We also send python code and execute it directly. Shaun, I know this is more than you were originally asking, but I wanted to make clear that there are a great many possibilities depending on your particular need. If you just need to be able to run python code then you may want to look into eclipse as an IDE. There are a lot of options there. -Judah On Mon, Feb 1, 2010 at 8:34 AM, AK Eric warp...@sbcglobal.net wrote: To my knowledge, Maya intercepts incoming commands as mel, irregardless of send methodology. You can send any type of data you want to Maya over the socket... but Maya will expect it to be mel when it receives it. I've not used MayaPad, but maybe it does something similar to what I do to work around this issue. Goes more or less like this: Open command port in Maya. In external app connect to that socket, save python code out as temp.py file. Ping Maya through command port to exec on temp.py. I do this via the API of my IDE: I can query what is hilighted, save that out as temp.py, and then have Maya execute it... lets me bypass the Maya script editor entirely. As an aside: While you can open a socket with both mel and Python... I've found that no matter what I do, if I open a socket with Python, the above solution won't work.. I have to open it with mel. Frustrating. On Feb 1, 6:27 am, Jo Jürgens jojurg...@gmail.com wrote: MayaPad does just that. Its a wxPython Python editor that can send commands to Maya. Maybe you can copy the way its done there http://code.google.com/p/mayapad/ On Mon, Feb 1, 2010 at 9:05 AM, Shaun Friedberg sh...@pyrokinesis.co.nz wrote: Right, perhaps I miss-spoke… I use Python to open a socket and then send Mel code. My question is does anyone know how to send Python code instead of Mel… -- http://groups.google.com/group/python_inside_maya -- http://groups.google.com/group/python_inside_maya
[Maya-Python] Re: commandPort
here's a quick and dirty way: import socket import re stringOPy = print howdy class X(): def __init__(self): print in X.__init__ x = X() stringOPy = stringOPy.replace('','\\') stringOPy = re.sub(\n,n,stringOPy) print stringOPy HOST = 'localhost' PORT = 7720 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) s.send(python(\+ stringOPy + \)+ \n) s.close() On Feb 1, 11:34 am, AK Eric warp...@sbcglobal.net wrote: To my knowledge, Maya intercepts incoming commands as mel, irregardless of send methodology. You can send any type of data you want to Maya over the socket... but Maya will expect it to be mel when it receives it. I've not used MayaPad, but maybe it does something similar to what I do to work around this issue. Goes more or less like this: Open command port in Maya. In external app connect to that socket, save python code out as temp.py file. Ping Maya through command port to exec on temp.py. I do this via the API of my IDE: I can query what is hilighted, save that out as temp.py, and then have Maya execute it... lets me bypass the Maya script editor entirely. As an aside: While you can open a socket with both mel and Python... I've found that no matter what I do, if I open a socket with Python, the above solution won't work.. I have to open it with mel. Frustrating. On Feb 1, 6:27 am, Jo Jürgens jojurg...@gmail.com wrote: MayaPad does just that. Its a wxPython Python editor that can send commands to Maya. Maybe you can copy the way its done there http://code.google.com/p/mayapad/ On Mon, Feb 1, 2010 at 9:05 AM, Shaun Friedberg sh...@pyrokinesis.co.nzwrote: Right, perhaps I miss-spoke… I use Python to open a socket and then send Mel code. My question is does anyone know how to send Python code instead of Mel… -- http://groups.google.com/group/python_inside_maya
[Maya-Python] Re: commandPort
Interesting, thanks for the tip, I'll give that a shot. I'm the first to admit I'm no socket expert ;) On Feb 1, 9:41 am, Marc Downie m...@openendedgroup.com wrote: As an aside: While you can open a socket with both mel and Python... I've found that no matter what I do, if I open a socket with Python, the above solution won't work.. I have to open it with mel. Frustrating. Well, at least on the mac I can state that this doesn't happen. We open sockets (port 1024) from Python all the time and they work like sockets. Are you sure you are getting the threadding right for executing the incoming python ? It seems to me that you have to use executeInMainThreadWithResult() [1] in order to have a socket server actually run code that it recieves. Marc [1]http://download.autodesk.com/us/maya/2009help/index.html?url=Python_P... -- http://groups.google.com/group/python_inside_maya