本文共 1481 字,大约阅读时间需要 4 分钟。
1. download the maya develop kit
https://apps.autodesk.com/MAYA/en/Detail/Index?id=6303159649350432165&appLang=en&os=Win64
then extract to C:\Program Files\Autodesk\Maya2016
2. set environmental variable:
MAYA_PATH = c:\Program Files\Autodesk\Maya2016
add c:\Program Files\Autodesk\Maya2016\bin; to Path
3.new a plain C++ Application project
4.overwrite the .pro file as follows:
TEMPLATE = libTARGET = HelloCONFIG += console c++11CONFIG -= app_bundleCONFIG -= qtQMAKE_EXTENSION_SHLIB = mllQMAKE_LFLAGS = /export:initializePlugin /export:uninitializePlugin /SUBSYSTEM:WINDOWS_CFLAGS = /FD /GSQMAKE_CFLAGS += $${_CFLAGS}QMAKE_CXXFLAGS += $${_CFLAGS}SOURCES += \ main.cppDEFINES += WIN32 \ _WIN64 \ _WINDOWS \ _USRDLL \ NT_PLUGIN \ REQUIRE_IOSTREAM \ _BOOLINCLUDEPATH += $$(MAYA_PATH)/include \QMAKE_LIBDIR += $$(MAYA_PATH)/libLIBS += -lFoundation -lOpenMaya -lOpenMayaUI#OBJECTS_DIR = ""5. create a c++ source file and write into it with following contents:
#include6. Now we can copy the Hello.mll to C:\Program Files\Autodesk\Maya2016\bin\plug-ins#include #include DeclareSimpleCommand( HelloMaya , "NCCA", "Maya 2016") //HelloMaya is the class nameMStatus HelloMaya::doIt( const MArgList& ){ std::cout<<"This should come from the shell\n"<
7.open maya, type and execute HelloMaya in maya command shell
note: the command HelloMaya is the class name not the plugin's name.