MAXScript Plug-in Basics

MAXScript plug-ins do not generally use ClassDesc so their .cpp and .def files are simpler, because they do not export the functions GetClassDesc() and GetNumClasses(). A MAXScript plug-in DLL should have the file-extension .dlx.

The following is a typical MAXScript plug-in .def file:

LIBRARY PluginName
EXPORTS
    LibDescription    @1
    LibInit          @ 2
    LibVersion       @3
SECTIONS
.data READ WRITE

The following is a typical MAXScript plug-in .cpp file:

#include "maxscrpt.h"
HINSTANCE hInstance;
 
// ========================================================
// Grab onto this DLL's instance handle
BOOL WINAPIDllMain(HINSTANCEDLLhinst, DWORDfdwReason, LPVOIDlpvReserved)
{
   switch (fdwReason)
   {
   case DLL_PROCESS_ATTACH:
     hInstance = DLLhinst;
     break;
   }
   return TRUE;
}
 
__declspec (dllexport) voidLibInit()
{
   // TODO: Put any code for initializing your plug-in here.
   MessageBox(NULL, _T("My MAXScript plug-in is loaded!!"), _T("Testing!"), MB_OK);
}
 
__declspec (dllexport) constTCHAR* LibDescription()
{
   // TODO: Put code in here telling what your plug-in does.
   return _T("My MAXScript plug-in");
}
 
__declspec (dllexport) ULONGLibVersion()
{
   // Return the version of the Max SDK
   return VERSION_3DSMAX;
}