Notifications
Clear all

[Closed] 3dsmax SDK to run maxscript question

Hi,
I spent a whole day to find out on how to use C++ to build a plugin like .dlu .dlm to run a piece of maxscript code,what I want to run a maxscript function like this:


fn Test_c=
(
a=123
print a
)
Test_c()

That’s all! (I don’t want to use c# to build a dll)But I am a newer for sdk,I have confused about 3 things:
1.There is an ExecuteMAXScriptScript can do this,but I did not find a tutorial talk about how to it,the autodesk link is here 
2.If I want use ExecuteMAXScriptScript to run maxscript,which plugin type shall I build, .dll?.dlu?.dlm?Or no limit fo any type?
3.If just to run that function,do I need to build all versions of 3dsmax sdk from C++,or just a lower version to fit all higher versions?
Thanks in advance if anyone can help!

3 Replies
  1. there are several ways to run MXS function (actually I know two). If you use ExecuteMAXScriptScript the function must be Global or path to the function must be Global
  2. you can use any type to execute script, but you should use the type that matches your goal (mxs extension, utility, modifier, etc…). More likely in your case it’s .DLX (mxs extension)
  3. in general case (to be safe) you have to build your plugin for all versions you want to support
2 Replies
(@momo2012)
Joined: 11 months ago

Posts: 0

Hi denis,thanks for point me to a right direction,really professional answer,I am clear now!

(@momo2012)
Joined: 11 months ago

Posts: 0

Oh,denist,I have a last question about this case,I spent another whole day to understand how sdk work and compile,I tested in a gup type,below is the code created by system:


#include "test.h"
#define test_CLASS_ID   Class_ID(0xd42b4dbd, 0x496b1563)
class test : public GUP {
   public:
      static HWND hParams;
      // GUP Methods
      DWORD      Start         ( );
      void      Stop         ( );
      DWORD_PTR   Control         ( DWORD parameter );
      
      // Loading/Saving
      IOResult Save(ISave *isave);
      IOResult Load(ILoad *iload);
      //Constructor/Destructor
      test();
      ~test();      
};
class testClassDesc : public ClassDesc2 
{
public:
   virtual int IsPublic()                      { return TRUE; }
   virtual void* Create(BOOL /*loading = FALSE*/)       { return new test(); }
   virtual const TCHAR *   ClassName()          { return GetString(IDS_CLASS_NAME); }
   virtual SClass_ID SuperClassID()             { return GUP_CLASS_ID; }
   virtual Class_ID ClassID()                   { return test_CLASS_ID; }
   virtual const TCHAR* Category()             { return GetString(IDS_CATEGORY); }
   virtual const TCHAR* InternalName()          { return _T("test"); }   // returns fixed parsable name (scripter-visible name)
   virtual HINSTANCE HInstance()                { return hInstance; }               // returns owning module handle
   
};
static testClassDesc testDesc;
ClassDesc2* GettestDesc() { return &testDesc; }
test::test()
{
}

test::~test()
{
}
// Activate and Stay Resident
DWORD test::Start( ) {
   
   #pragma message(TODO("Do plugin initialization here"))
   
   #pragma message(TODO("Return if you want remain loaded or not"))
   return GUPRESULT_KEEP;
}
void test::Stop( ) {
   #pragma message(TODO("Do plugin un-initialization here"))
}
DWORD_PTR test::Control( DWORD parameter ) {
   return 0;
}
IOResult test::Save(ISave *isave)
{
   return IO_OK;
}
IOResult test::Load(ILoad *iload)
{
   return IO_OK;
}


So where shall I put the ExecuteMAXScriptScript() code?I tried put them in that code,but did not success.


ExecuteMAXScriptScript("global Test_c2=1;fn Test_c=(a=123;print a);Test_c();");