3

I'm building a tool to control maya with it and I'm trying to connect to maya's commandport through node webkit to send commands but with no success. I opened the port from maya with mel:

commandPort -n "127.0.0.1:6000";
string $p = `commandPort -q "127.0.0.1:6000"`;
if ($p == 1) {print "CommandPort Opened \n";}
if ($p == 0) {print "CommandPort Closed \n";}

And here is the code inside my html UI:

<script>    
var net = require('net');
var maya = new net.Socket();

maya.connect(6000, '127.0.0.1', function() {
    console.log('Connected');
    maya.write('polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -cuv 2 -ch 1;');
});
</script>

The console in node webkit shows that its connected but nothing happens inside maya.

I just got started with this whole node webkit thing and its pretty cool!!! I need your help to solve this problem.

Thank you all in advanced for any help :)

ABA3DD
  • 33
  • 4
  • 2
    you might want to try `commandPort -n ':6000' -eo` to see the commands echoed in your maya listener – theodox Jul 23 '14 at 02:20
  • This can not be debugged form afar, you might have all sorts of convolutions in the way. – joojaa Jul 24 '14 at 14:41
  • 1
    Your example worked for me, on Windows, using Maya 2015 and node.js – Marcus Ottosson Nov 05 '14 at 17:11
  • I know it's been 6 years, but I managed to run your code on my Node, and I'm extremely grateful, I had no idea about this part of the "new net.Socket()", and it would have taken me a long time to find it. For me, your only mistake is that you placed the Node code inside an HTML file, you need to place the code inside an archive.js and run the "node archive.js" command to execute the Node functions. Thanks for sharing your code! – KevynTD Jun 12 '20 at 02:43

0 Answers0