Basic Use Of Maya's Command Port

This is a basic tutorial on how to use the command port in Maya. By opening the command port we can send Mel commands to Maya remotely. This can become very handy later in the plugin development process. The iteration through the phases of coding, compiling, loading the plugin, testing and finally unloading the plugin, can be shortened and well integrated with you favourite IDE (whether it's Emacs or KDevelop for instance)
Follow these 5 simple steps and you will be able to make basic use of the Maya command port.
1. Start Maya
$ maya
2. Open Script Editor
Inside Maya look for "Window" in the top menu.
Window -> General Editors -> Script Editor
3. Open the Command port in Maya
In the Script Editor write:
commandPort -n "localhost:6000";
Where 6000 is the port number (choose a unused port number between 1024 and 65000).
Execute the command by pressing <Ctrl> <Enter> at the same time (or Command -> Execute from the menu)
Now the command port is open to the outside world, making it possible to execute Mel commands remotely.
4. Connect to the Command Port
I order to send Mel commands to the machine running Maya with the command port open you can use telnet.
Usage: telnet <host> <port>
I our case we could write:
$ telnet localhost 6000
Response:
tic@mtic:~/$ telnet localhost 6000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
5. Send actual commands to Maya
We could start by making Maya draw a sphere with the radius of 5.
In the telnet session just write:
sphere -r 5
or if we would like a torus just write:
polyTorus
The geometry will now appear in your Maya scene.
Get help to the command by typing:
help <commandName>
This will give you a list of all Mel commands starting with the letter a:
help -list "a*"
This was just a quick intro to the command port which we are going to use later on in upcoming tutorials on plugin development.
Check out this screenshot from the above test (click on the picture to enlarge)
- 20.12.2006. 21:06 | Author: Ticless
Comments
mason - 30.10.2009. 22:59
to fix the above problem enter this command before attempting to use telnet:
tlntadmn config mode=console
Rachit - 08.02.2009. 00:28
try this
telnet localhost 6000 then press enter and then press Ctrl+]
this will put you on the telnet command prompt and then you can use the "send" command to send strings to maya. so like
send print "Hello";
I hope that helps
max - 21.10.2008. 21:31
Nicolas:
it doesn't, window's telnet is a piece of crap. Any tcp client that can send full strings should work fine though.
ENZYME - 18.02.2008. 23:20
I have same problem like Nicholas. Is there a solution for this? In fact I have this issue of my computer unable to make connection from external web browser to Maya through port commandportDefault.
akadarky - 09.12.2007. 15:30
I ve got the same problem with telnet,
you can use putty to solve this issue :)
James - 25.11.2007. 23:17
I'm having a problem and maybe you can help. When i try to Batch Render anything i get this mesage in the script editor,
"// Error: Could not create command port : DOOM:7835".
Any ideas?
Nicolas - 06.01.2007. 16:53
Hi Tic,
I tried putty, and actually, it works well... But another problem arises when I try to use plink to automate the process to sending commands from ultra edit for example...
Nothing happens.
Actually, I'll continue investigating, and experimenting, but I wait for your tutorial... ;)
Thanks for sharing.
Nicolas
Ticless - 06.01.2007. 15:29
Hi Nicolas
The problem is windows telnet sends each character separate as default. Dont know if putty does the same? Try other applications for the telnet session or wait a couple of days and I will post a tutorial on how to write your own :)
/tic
Nicolas - 06.01.2007. 13:38
Hi,
I was wondering which options to give telnet on windows to have the same functionality as you describe here. Because all I get are errors from maya, as it seems not to interpret the whole commands passed to him, but each character as a command. Example: print "helloWorld'; woudl return those errors:
// Error: line 1: Cannot find procedure "p". //
// Error: line 1: Cannot find procedure "r". //
// Error: line 1: Cannot find procedure "i". //
// Error: line 1: Cannot find procedure "n". //
// Error: line 1: Cannot find procedure "t". //
// Error: "; //
// Error: Line 1.3: Unterminated string. //
// Error: line 1: Cannot find procedure "h". //
// Error: line 1: Cannot find procedure "e". //
// Error: line 1: Cannot find procedure "l". //
// Error: line 1: Cannot find procedure "l". //
// Error: line 1: Cannot find procedure "o". //
// Error: line 1: Cannot find procedure "W". //
// Error: line 1: Cannot find procedure "o". //
// Error: line 1: Cannot find procedure "r". //
// Error: line 1: Cannot find procedure "l". //
// Error: line 1: Cannot find procedure "d". //
// Error: "; //
// Error: Line 1.3: Unterminated string. //
Is there something I'd have overlooked?
Write a comment