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

Reply via email to