View Full Version : sending raw MEL code over Python socket connection

02 February 2011, 01:13 AM
I got annoyed that BBEdit doesn't have the ability to natively send MEL to Maya so I started playing around imitating how Textmate does it (with commandPort) and am very close to having something working. It's fine with single lines of code but once you get line breaks, they need to be escaped or Python chokes on the execution:

$>python /tmp/ (contents:)

import socket
maya = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
maya.connect(("", 5055))

Maya_text = "sphere;
string $mySelection[] = `ls -sl`;
print $mySelection[0];"

I'm not familiar with Python, so I'm wondering if there's a way to tell it to send the text without choking on the syntax, or should I write my stdout MEL contents to a file and have Python pipe that through the socket? Textmate uses Ruby so maybe this is an easier way to do it. Dunno.

02 February 2011, 01:52 AM
nevermind - I got it working, with no hassles with Ruby. Easier too since it's easier to work with stdin with Ruby. This works great with huge pieces of code:


02 February 2011, 05:39 PM
someone helped me with a Python version, in case someone was wondering what the code looks like.

Be curious to see if someone could get something similar working in Linux. It would probably have to work with pasteboard contents or something since there's no Automator for Linux. But stdin, Python, etc are the same

CGTalk Moderation
02 February 2011, 05:39 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.