The following provides information on how to write a simple plug-in called Hello World.
When learning a new computer language, the first program you are likely to see is a "Hello World" program. Following this tradition, the first plug-in we create is a "Hello World" plug-in, which simply outputs "Hello World" to the window from which Maya was launched.
#include <maya/MSimple.h> #include <maya/MIOStream.h> DeclareSimpleCommand( helloWorld, "Autodesk", "2017"); MStatus helloWorld::doIt( const MArgList& ) { cout << "Hello World\n" << endl; return MS::kSuccess; }
If this is put into a file called helloWorld.cpp it can be compiled with:
g++412 -c -I. -I.. -I/usr/autodesk/maya2017/include -I/usr/X11R6/include -m64 -O3 -pthread -pipe -D_BOOL -DLINUX_64 -DREQUIRE_IOSTREAM -fPIC -mtune=pentium4 -Wno-deprecated -fno-gnu-keywords helloCmd.cpp g++412 -shared -m64 -O3 -pthread -pipe -D_BOOL -DLINUX -DREQUIRE_IOSTREAM -mtune=pentium4 -Wno-deprecated -fno-gnu-keywords -Wl,-Bsymbolic -shared -o helloCmd.so helloCmd.o -L/usr/autodesk/maya2017-x64/lib -lOpenMaya -lFoundation
If this is put into a file called helloWorld.cpp, it can be compiled by following the platform-specific instructions in Creating your own plug-in build file for the Windows environment and Mac OS X environment.
Once the file has compiled, you can load it into Maya (see Loading a Plug-in). Type "helloWorld" into the command window (press Enter to invoke the command), and "Hello World" displays in the output window.