Read and respond to this message at: 
https://sourceforge.net/forum/message.php?msg_id=4732365
By: orenouard

You're right it's not PyDev specific, any kind of text from the text editor
could be sent that way, as long as you know the command to communicate it to
the target application.

The thing is many Maya user switching to Python and looking for a good editor
/ IDE t the moment. And several users where I work have expressed they missed
the possibility of other editors (like Jedit) to send code snippets to Maya
in such a way. I know we are comparing apples and oranges here as an editor
isn't an IDE like eclipse, and PyDev isn't the whole of Eclipse or even limited
to a Text Editing extension.

I'm also aware that when working on larger scale scripting projects, you'd be
better off building modules and loading them in the host application rather
than doing direct testing that way. But many casual scripters in the 3D studios
work on small code functions or even direct "utility" scripts, and with Maya
being more or less the leading DCC application switching to Python support,
these is a lot of interest currently in finding good Python IDEs to use. Though
Eclipse is arguably oversized for day to day script hacking in Maya, once you
start doing more and organizing a larger script base I find it really great
(being able to share the same IDE as for C/C++ work is an added benefit too).

Actually there is no need for the extensions, the Eclipse "filter" (the 
"shift+alt+|"
shortcut thing), will work if you define the correct command. For the couple
of people who use PyDev with Maya I seen here (seen 2 of us so far :) ), if
you want, it's very rough but basically working :

Open a command port in Maya :

commandPort -n "mayaCommand:7899";

Create a new command to send the std input to Maya, for instance on Linux with
this small Python script "pipeToMaya"

#!/usr/bin/python
import socket, sys
port = 7899
f = sys.stdin
lines = f.readlines()
f.close()
script = ""
multiLine = False
if len(lines) == 1 :
        script = lines[0].replace('"', '\\"').strip('\n')
else :
        for l in lines :
                script += l
        script = script.replace('\n', '\\n').replace('"', '\\"')
        multiLine = True
# Annoying Maya call to Python formatting
command = 'python("%s")' % script
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('localhost',port))
if multiLine :
        sock.sendall(command)
else :
        sock.send(command)
        ret = sock.recv(4096)
        if ret is not None :
                print ret
sock.close()

Use "shift+alt+|" and enter "pipeToMaya" as command (for instance saved the
script as such in /usr/local/bin and made it executable), and check "direct
filter output to console".

Of course would be more practical as a full fledged Eclipse Text Editor plugin,
to be able to to that on a single button / option press and maybe to be able
to change the port number, and application name in preferences, but I don't
know enough about Eclipse pluging development or Java for that.

Does it have an interest for other applications using an embedded Python 
interpreter
I don't know, I have no idea if there are cases where it is handy to be able
to send Python code snippets to the host application in a similar way of if
Maya is just a peculiar case here.





______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit: 
https://sourceforge.net/forum/unmonitor.php?forum_id=293649

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Pydev-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pydev-users

Reply via email to