Skip to content

Plugin template repository for Autodesk Maya. Uses cmake. Configured for CLion.

License

Notifications You must be signed in to change notification settings

DanilAndreev/maya-plugin-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

Maya plugin template

C++ plugin template for Autodesk Maya.

GitHub release (latest by date) GitHub GitHub Repo stars GitHub forks
Maya icon CMake icon C++ icon

Overview

This is a template repository for creating Autodesk Maya plugin using C++ Maya API and CMake. Using this template you can easily start plugin development and don't care about setting up CMake and confuguring build.

Usage

I recommend you to use this template with JetBrains CLion because the project were set up in this IDE. But you always can use it with pure CMake.

For best practise you should use CLion version higher or equal to 2021.1.

Setting up project

Open CMakeLists.txt file in the repository root and change maya-plugin-template to your project name. Also, you can change description to your text.

project(maya-plugin-template VERSION 1.0 DESCRIPTION "My Maya Plug-in" LANGUAGES CXX)

Writing code

Use src directory for source code. You can organise directories in src as you wish. For example, create next structure:

.
├── src
│   ├── include
│   └── source
└── ...

To add source files to the project simply add this files to src/CMakeLists.txt file to field SOURCE_FILES at the top of the file.

set(SOURCE_FILES
        HelloWorld.cpp
        HelloWorld.h
        plugin.cpp
        plugin.h
        )

If you are using CLion - files will be added automatically. You don't have to care about that.

Connecting Maya API

  1. Download Maya Development Kit (MDK) for your OS.
  2. Rename MDK directory to maya_dev_kit
  3. Place MDK to libraries directory as shown below:
    .
    ├── libarires
    │   ├── maya_dev_kit
    │   │   ├── include
    │   │   ├── lib
    │   │   └── ...
    │   ├── .gitignore
    │   └── README.md
    └── ...
    

Building plugin

CLion

First you need to prepare project for build.

  1. Go to File->Settings->Build, Execution, Deployment->CMake.
  2. Select profile you need for development. It depends on your toolchain and OS.
  3. Check the Enable profile checkbox on profile you need and uncheck on other.
  4. Open CMake panel. (by default at the bottom of your editor window)
  5. Press Reload CMake Project button.

After that you can select run configuration and build project.

Pure CMake

UNIX using MinGW and Make
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" -DMAYA_VERSION=none ../
cmake --build . --target YOUR_PROJECT_NAME -j 3
Windows using MVSC
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G "Visual Studio 16 2019" -A x64 -DMAYA_VERSION=none ../
cmake --build . --target YOUR_PROJECT_NAME -j 3

If you want to compile for release - change -DCMAKE_BUILD_TYPE flag from Debug to Release.

Credits

Author Danil Andreev.
Thanks to Chad Vernon for the cgcmake library.