The Maya Development Kit product contains a number of example plug-ins located in C:\Program Files\Autodesk\maya2009\devkit\plug-ins. The development kit also contains several Maya API applications, located in C:\Program Files\Autodesk\maya2009\devkit\applications.
Before you can use the example plug-ins, you need to build them. You can choose to build the plug-ins in the directory to which they were installed or you can copy the plug-ins to your own working directory.
To build an individual plug-in, you need to load the corresponding solution file (the .sln file) into Microsoft Visual Studio 2005 Visual C++.
The easiest way to do this is to open Visual C++ and drag and drop the .sln file onto it. When the workspace is loaded, you can select Build Solution from the Build menu. Visual C++ will build your plug-in and place the resulting .mll file in the current directory.
To build all of the example plug-ins, you need to load the Plugins.sln workspace file into Visual C++. As above, the easiest way to do this is to open Visual C++ and drag and drop the Plugins.sln file onto it. When the workspace is loaded, you can select Rebuild Solution from the Build menu.
To load your plug-in into Maya, open the Plug-in Manager window and browse to the directory containing your plug-in. If you want the Plug-in Manager to automatically find your directory, you can build and put the plug-in into a directory defined by the MAYA_PLUG_IN_PATH variable.
You can choose to build the applications in the directory to which they were installed or you can copy the applications to your own working directory.
To build an individual application, you need to load the corresponding workspace file (the .sln file) into Microsoft Visual C++. The easiest way to do this is to open Visual C++ and drag and drop the .sln file onto it.
When the solution is loaded, you can select Build Solution from the Build menu. Visual C++ will build your application and place the resulting executable file in the C:\Program Files\Autodesk\Maya2009\devkit\applications directory.
To build all of the example Maya API applications, you need to load the APIApplications.sln workspace file into Visual C++. As above, the easiest way to do this is to open Visual C++ and drag and drop the APIApplications.sln file onto it. When the workspace is loaded, you can select Rebuild Solution from the Build menu.
If, during installation, you added the Maya executable directory to your path, you can run the application immediately. If you did not, you will need to copy your application to the Maya executable directory to run it.
Several environment variables must be set in order to run a standalone Maya API application. These are:
set MAYA_LOCATION=c:\Program Files\Autodesk\Maya2009
set Path=c:\Program Files\Autodesk\Maya2009\bin;%Path%
Note that %Path% is included so that existing commands are not lost to the shell.
Creating your own plug-in build file
The instructions in the previous section enable you to build and use the example plug-ins included with Maya, but you still need information on creating your own plug-ins. On Windows, the process for creating the source code files is the same as it is on Linux, but in addition you must create Microsoft “Project” files so that Developer Studio knows how to build the plug-in. You can do this using the plug-in wizard, described in the following sections.
Using the Maya Plug-in Wizard for Developer Studio
A “Maya Plug-in Wizard” is provided for both the 32 and 64-bit versions of Maya. This wizard makes it very easy to create project files for your plug-in. It is highly recommended that you use this wizard.
To install this wizard, please follow the instructions contained in the $MAYA_LOCATION/devkit/pluginwizard directory.
To use the wizard, select File > New Project in Microsoft Visual Studio, then select Visual C++ Projects from Project Types and then finally select “Maya Plug-in Wizard” from the Templates area. The wizard will prompt you for the name of the plug-in, the type of plug-in (e.g. Command, Node, Tool, etc.) and the list of libraries the plug-in requires for linking. When you have answered all the questions, the wizard will create a complete project that contains the needed .sln and .vcproj files, and a complete template of the code needed to create your Command, Node, Tool, etc. This plug-in will compile without any changes, and will be a “do nothing” version of the type of plug-in you specified to the wizard. You just need to edit the .h and .cpp files and add the logic for your plug-in.