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

> Hi,
>
> I'm sending a command through the commandPort (from a C# server) and it
> executes a bunch of other python commands in Maya. I get the response in my
> Maya console but none of this is being passed onto the C# server through
> the commandPort. The C# server prints 'None' (breakpoints) the same moment
> my Maya console is populated by the logs from the python code.
>
> This is what opens the commandPort:
>
> cmds.commandPort(name="localhost:8010", bufferSize=4096,
> sourceType="python", noreturn=False)
>
> On the C# side, I have a NetworkStream.Read() that's fetching the data.
>

There is a difference between the logging I/O output and the return value
of the function.  When I write a function like this:

def add(x, y):
    z = x + y
    print "OUTPUT:", z
    return z

I set the OUTPUT go to the Maya script editor, and the value 3 is returned
in the commandPort stream. But one thing to be aware of is that if your
command has multiple statements separated with a semicolon, then None will
be returned:

$  echo '1+1 ; 2+2' | nc localhost 8010
None

$  echo '2+2' | nc localhost 8010
4

So if you need to send a bunch of logic, you might need to wrap it into a
function and then have it return your output.


> TIA
>
> --
> 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/1e7024ea-354e-47a2-a9ca-05bb91c57149%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/CAPGFgA1VUzVOBGAsp7%3DH38qTMVVkzSkH0aOsUQ61q57hctDEFA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to