On Wednesday, 9 January 2019 19:40:32 UTC-8, Justin Israel  wrote:
> On Thu, Jan 10, 2019 at 2:26 PM <unnikris...@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.

I'm doing something similar to what you said. I tried with the '|' operator but 
I was getting syntax errors returning through the commandPort. The below 
command is what I'm sending through the commandPort:

import maya.cmds ;
import os ;
proj_root = os.environ['PROJ_ENV'] ;
import sys ;
sys.path.append(proj_root + '\\plugins\\python\\maya') ;
import pluginTest ;
import imp ;
imp.reload(pluginTest) ;
pluginTest.SaveTest.save_file() ;

I'm only calling this function and its supposed to return the value once it's 
done. But I keep getting None as the response.

-- 
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/d2168720-a3c0-416b-8dd8-2ee6731010da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to