On Thu, Jan 10, 2019 at 1:13 PM <unnikrishnan.a...@gmail.com> wrote:

> On Wednesday, 9 January 2019 12:25:40 UTC-8, Justin Israel  wrote:
> > On Thu, Jan 10, 2019 at 9:05 AM <unnikris...@gmail.com> wrote:
> > Hi,
> >
> >
> >
> > I've been using Maya commandPort to input commands into Maya and it
> works fine.
> >
> >
> >
> > I was wondering if there's a way to fetch the input command that's
> coming through the socket? This way, I don't want to send a command but
> send a string which invokes a function in my python code inside Maya.
> >
> >
> >
> > Is there some form of listener I can add to the commandPort command in
> Maya?
> >
> > I have echoOutput=true and that echoes the output as it says. But I
> can't seem to catch the string that's coming through the socket.
> >
> >
> >
> > There is no hook to allow you to intercept the data on the commandPort
> socket before the commandPort evaluates the input. But this hook isn't
> actually neccessary. If you have created a python sourceType commandPort,
> then every string you are sending is evaluated as python source code. This
> may invoke whatever function you want (you can even use a python() call
> from MEL if its a default mel commandPort). So you may create whatever hook
> you want in Maya and invoke that as you see fit.
> >
> >
> > If you want a reference for this kind of logic you can review the work I
> have done on the MayaSublime project:
> >
> >
> > https://github.com/justinfx/MayaSublime/blob/master/MayaSublime.py
> >
> https://github.com/justinfx/MayaSublime/blob/master/lib/pubScriptEditor.py
> >
> >
> > This plugin is responsible for running code from your SublimeText editor
> remotely within Maya over the commandPort. One aspect of that process is
> how it handles shuttling back the output text. The plugin will push a
> custom bit of code over the commandPort to be created in the Maya
> environment to install callbacks and open custom sockets.
> >
> >
> >
> >
> >
> > Thanks.
> >
> >
> >
>
> Thanks a lot Justin! As a follow-up, is there a way to know once I've
> performed certain Maya python commands. Like passing a success/failure? Do
> I write into the standard IO for the socket to pick it up or is there a
> better way of handling the same? Maybe by opening a new port and send the
> reply on that?
>

commandPort has the option to return the output from your commands, but I
find it very limiting since it has a max size that could hit and kill your
port. So in MayaSublime I open my own socket and take care of returning
output.


>
> --
> 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/727e7469-94f6-4a3f-a1c1-9f3eacd65949%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAPGFgA11qMZa7YpXMJnXDgJyNnZ_CDL%2BK-28Cm%2BNgaDzR_sRDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to