It has always been cumbersome to build and load the C++ plugins available in the Maya devkit and, ever since Maya 2019, the Maya Windows devkit doesn’t even include a Visual Studio Solution to build its example plugins with just a few clicks. Let’s not even mention what to do when there are also scripts involved…
As I find myself often building and testing out plugins in the devkit, I decided to document and share a simple workflow that I use to facilitate this.
Let’s get right to it.
- Autodesk Maya (2019+)
- CMake (download and install)
- Visual Studio Community 2019 (download and install)
- Maya devkit (download)
Once we have downloaded and installed everything, we need to extract the contents of the Maya devkit (devkitBase folder) in a directory of your choosing (e.g.,
C:\DEV\devkitBase). From now onwards, we will call this directory
Making sure Maya finds the plugins you build
With the devkit extracted, we need to make sure Maya will be able to find the plugins that we build. For this purpose, you need to add some environment paths to the version of Maya that you are using.
To do this, you need to go to
documents\maya\2020 (change “2020” to the version of Maya you are targeting) and open the Maya.env file in a text editor (Notepad should do just fine). Within Maya.env, add the following environment variables, replacing
%DEVKITBASE% with the directory where your devkitBase folder is in.
Save and close the text editor. These variables will allow Maya to find the plugins next time you start the program.
Now that the setup is complete, we need to build the plugin and put the files in the respective folders for Maya to find them. To do this, you can use a small batch script that automates this process. You can download the build.bat batch script here and place it in
If you prefer creating the batch file yourself (some Browsers might flag .bat files by default as harmful) you can open Notepad and copy/paste the following:
@echo %off rem We make sure the right folder structure exists set DEVKIT_LOCATION=%~dp0% if not exist %DEVKIT_LOCATION%\build md build if not exist %DEVKIT_LOCATION%\build\plug-ins md build\plug-ins if not exist %DEVKIT_LOCATION%\build\scripts md build\scripts rem We ask the user for what version of Maya and what to build set /p M_YEAR=Maya version (year): set MAYA_LOCATION="C:\Program Files\Autodesk\Maya%M_YEAR%" set PATH=%PATH%%MAYA_LOCATION%\bin; set /p PLUGIN_NAME=Plugin name (folder): cd devkit\plug-ins\%PLUGIN_NAME% rem We build the plug-in cmake -H. -B build -G "Visual Studio 16 2019" cmake --build build rem We move the build files to our custom build folder for /R .\build\Debug\ %%f in (*.mll) do copy "%%f" %DEVKIT_LOCATION%\build\plug-ins\ for /R .\ %%f in (*.mel) do copy "%%f" %DEVKIT_LOCATION%\build\scripts\ echo: echo Plug-in %PLUGIN_NAME% build and copied! echo: pause
Once pasted, you need to save the file in the
%DEVKITBASE% directory with the
.bat extension e.g.,
build.bat file ready, we can run it. Once opened, the command prompt will appear and ask you for what version of Maya you want to build a plugin.
Just enter the number version of Maya e.g.,
2020 and hit Enter.
Afterwards, it’s going to ask you for the plugin name inside of the devkit. You can find all available C++ plugins in
Just enter the name of the folder of the plugin e.g.,
animExportUtil and hit Enter.
The batch script will then proceed to build the desired plugin and put the build files inside the build folder at the
That’s it, start Maya again and you should be able to automatically see the plugin in Maya’s Plug-in Manager (
The built files will reside in the build folder at the
%DEVKITBASE%, but you can still find the created Visual Studio Solution in its plugin folder
%DEVKITBASE%\devkit\plug-ins\YOURPLUGIN\build\Project.sln. There are plenty of other ways to build Maya devkit plugins, however, this is enough for my testing needs.
I hope this small article makes someone’s life a bit easier when building Maya devkit plugins in the future. If you found this article helpful, let me know in the comments below. We’d be happy to do future articles on writing plugins or NPR dev.
Until next time!