To a certain extent, the development of the Maya export plug-in is easier than the export of Max, and you can do a lot less on your own.
This is a python plug-in, which can basically be used in C ++.
First, let's take a look at Maya's environment variable settings.
In my document, the Maya/Maya version \ Maya. env; for example, c: \ Users \ sitt \ Documents \ Maya \ 2011-x64 \ Maya. env
You can use NotePad to open this file and add a line.
Maya_plug_in_path = your own plug-in path.
For example:
Maya_plug_in_path = D: \ mayaplugin \
In this way, Maya adds the path to the directory of the plug-in. You can load the plug-in from this directory.
Next, it is nice that the Mel of Maya has functions for uninstalling and loading plug-ins. Max has a third-party plug-in to implement similar functions. However, after all, it is not as good as the built-in software. Max will have time to post it later.
The code used to uninstall and load the plug-in by Mel is:
unloadPlugin "ModelTranslator.py";
loadPlugin "ModelTranslator.py";
Since it is an export, you also need to export a file to see if it works normally. Mel code:
file -op ""-typ "ModelTranslator"-pr -ea "C://testmodel.xxx";
"Modeltranslator" is a self-written export plug-in class. The export plug-in Maya must inherit mpxfiletranslator. How to write and export data.
You can also download the export plug-in of Maya at Oak 3d.com for reference. The code is public. :) This export is also written by me.
You can run the preceding three statements together. The result is to uninstall, reload the plug-in, and export the file. Is it convenient?
You can go further. Maya can listen to a port and run the sent string as a script. Here is the Mel for enabling the port. For python, refer to the functions with the same name in the Maya document.
if(! `commandPort -q ":7457"`) commandPort -rnc -n ":7457"
This is to check whether the local port 7457 has been registered. If it is not registered, it is enabled.
This can be automatically run at Maya startup by writing it in my documents Documents \ Maya \ <version> \ scripts \ usersetup. Mel
For example, c: \ Users \ sitt \ Documents ents \ Maya \ 2011-x64 \ scripts \ usersetup. Mel
This file is not available by default. You can change the name of a new text file.
Then, you can write a program that accepts command line parameters to send strings. A lazy like me uses C #. It's easy.
C # socket
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace SockCMD
{
staticclass Program
{
[STAThread]
staticvoid Main(string[] args)
{
if (args.Length <3) return;
string ipText = args[0];
string protText = args[1];
string message = args[2];
TcpClient theTcpClient =new TcpClient();
try
{
IPAddress theIP = IPAddress.Parse(ipText);
int prot = Int32.Parse(protText);
theTcpClient.Connect(theIP, prot);
NetworkStream theNetStream = theTcpClient.GetStream();
if (theNetStream.CanWrite)
{
byte[] theMessageBuffer = Encoding.ASCII.GetBytes(message);
theNetStream.Write(theMessageBuffer, 0, theMessageBuffer.Length);
}
}
catch
{ }
theTcpClient.Close();
}
}
}
If it is art or technical art, you can also download the http://files.cnblogs.com/sitt/SockCMD.zip I wrote, need to install. NET Framework, of course, has been installed.
The usage is "sockcmd IP address port character ".
Example: sockcmd 127.0.0.1 7457 polycube
If Port 7457 is registered, the result of executing sockcmd is to create a cube in Maya.
How is it? Do you know what to do?
You only need to set a command line bound to the key in your own editor to send the Mel script for re-loading the plug-in and exporting the file.
You can configure a convenient development environment by yourself.