Notifications
Clear all

[Closed] SDK tutorial

 MZ1

I’m absolute beginner at C++ programming, but I’m trying to explore the world of the Max SDK. I just want to learn and collect information and create a general tutorial for myself and other users who want to start from scratch. Again I don’t want to teach, I want to discuss and collect information which are not documented very well or are not enough for beginners. So this are my first challenges:
1 – How to create build environment:
Install Visual Studio, You can use Plugin Wizard to create files or you can configure project from scratch.(Example)
2 – How to write first “Hello World”.
3 – How I can learn SDK structure and organization? (link to documentations, help and tutorials).
4 – How to read SDK examples, modify and rebuild them.
5 – How to create floated dialog.
6 – how to integrate it with QT.
7 – Can I build a plugin for all 3dsMax versions?
No, you should update and built the code for every single version (64 or 32 bit also).
.
.
and this list will be increased and answered here as long as I learn. I really appreciate your help to complete this tutorial.

20 Replies
 MZ1

For 1 and 2 I just created a tutorial, please tell me what you think:

Make sure Visual Studio 2012 is installed.(Search “SDK Requirments” section to see which version you should install).
New Project > Visual C++ > General > Empty Project.
Build Mode: Release.
Build Platform: x64. If x64 is not exist, add it from configuration manager.
Source Folder > AddItem > New Item > C++ File (.cpp).
Project Configuration:
Configuration: Release.
Platform: x64.
General:
Target Extension: .dll
Platform Toolset: V110
Configuration Type: Dynamic Library (.DLL)
Character Set: Use Unicode Character Set
C/C++ > General:
Additional Include Directories: $(SolutionDir)Additional\Include;%(AdditionalIncludeDirectories)
C/C++ > Code Generation:
RuntimeLibrary: Multi-threaded (/MT)
Linker > General:
Additional Library Directories: $(SolutionDir)Additional\Library;%(AdditionalLibraryDirectories)
Linker > Input:
Additional Dependencies: bmm.lib;core.lib;geom.lib;gfx.lib;mesh.lib;maxutil.lib;maxscrpt.lib;gup.lib;paramblk2.lib;%(AdditionalDependencies)
Module Definition File = ModuleDefinition.def
Additional Libraries:
Create a folder in solution folder and rename it to “Additional”.
Copy Include(x64) folder from SDK to Additional\Include.
Copy lib(x64) folder from SDK to Additional\Library.
Create Files:
Source Folder > AddItem > New Item > ModuleDefinition.def, and paste the following code:


LIBRARY MaxPlugin.dlx
EXPORTS
   LibDescription          @1       PRIVATE
   LibNumberClasses        @2       PRIVATE
   LibClassDesc            @3       PRIVATE
   LibVersion              @4       PRIVATE
SECTIONS
   .data READ WRITE

Rename header name in the definition file as same as your plugin name.
Source Folder > AddItem > New Item > DllMain.cpp, and paste the following code:

#include <maxscript/maxscript.h>HINSTANCE hInstance;
BOOL WINAPI DllMain(HINSTANCE DLLhinst, DWORD fdwReason, LPVOID lpvReserved)
{
   switch (fdwReason)
   {
   case DLL_PROCESS_ATTACH:
      hInstance = DLLhinst;
      break;
   }
   return TRUE;
}

__declspec(dllexport) const TCHAR* LibDescription()
{
   return (_T("MaxScript Plugin"));
}

__declspec(dllexport) int LibNumberClasses()
{
   return 0;
}

__declspec(dllexport) ClassDesc* LibClassDesc(int i)
{
   return 0;
}

__declspec(dllexport) ULONG LibVersion()
{
   return VERSION_3DSMAX;
}


Paste this code in to the Source.cpp :

#include <maxscript/maxscript.h>#include <maxscript/macros/define_instantiation_functions.h>


def_visible_primitive(SampleFunction, "SampleFunction");
Value* SampleFunction_cf(Value **arg_list, int count)
{
   ExecuteMAXScriptScript(_T("print \"MaxScript Executed By DLL.\" "));
   return &ok;
}


MaxScript Example:

LoadDllsFromDir "C:/Users/Mehdi/Documents/Visual Studio 2017/Projects/TestPlugin/x64/Release/" "TestPlugin.dll"
SampleFunction()


because this text has special characters which is not showing here, please download complete files here:
 https://drive.google.com/open?id=1v16UTB2D2pimpt83QONPUSqO7ciqZ6EL 

Creating all those files and setups from scratch is not necessary.

Just install and run the plugin wizard, as explained in the SDK docs, and go from there. It’ll create all the necessary boilerplate for you and save you a lot of time and effort.

From that point, the easiest way to learn the SDK is to build and modify the example projects, getting a feel for how plugins are laid out, which functions and settings you need to override, etc. The example file code base is somewhat of a tutorial database on its own, considering the varying degrees of complexity of each plugin included. You can start small by studying the code for simple modifiers and objects, and eventually make your way to the more complex projects. I personally feel just giving a list of ‘todo’ steps to make a plugin is inferior to diving into existing code and playing around with it directly.

3 Replies
 MZ1
(@mz1)
Joined: 11 months ago

Posts: 0

Let say I want to create a simple transform controller that return identity matrix + offset. I just opened some controller examples from the SDk, but there are no comments in it, this makes progress too hard for me. another question is let say I want to know where the function “LerpCurve3D” is located? how I can learn about it? for C# I can find anything in MSDN documentation, but here I do’nt know where is it.

(@ivanisavich)
Joined: 11 months ago

Posts: 0

Fair enough. Regarding your second question there, in case you weren’t aware, there is a pretty complete SDK documentation online provided by Autodesk. A quick google for “InterpCurve3D” (the equivalent maxscript function) brought up the answer within the SDK as well. Obviously you just threw that out as an example, but I’m just pointing out that the max SDK documentation is actually quite helpful too.

 MZ1
(@mz1)
Joined: 11 months ago

Posts: 0

I got it .Which section I should search? “C++ API Reference”? Searching the keyword in documentation(2018) does query for all sections. I wish there was an easy method to filter query for only one specific section.

well not necessary to advanced user but to me its very helpful. Thanks MZ.

  • How to create floated dialog
  • how to integrate it with QT

well many more … just throw it all out man , I believe someone out there would be happy to read it.

1 Reply
 MZ1
(@mz1)
Joined: 11 months ago

Posts: 0

Yes, this was my goal. I just added your questions, Hopefully someone will answer it.Tanx

 MZ1

Never mind, I forget that there is filter section at the left side.

 MZ1

I just want to use wizard and I got following errors:

When I choose “Controller” type:

and when I choose rest of the types:

Note that I’m using VS 2017 and Max 2018. and changed Wizard=VsWizard.VsWizardEngine.15.0
also VS 2012 and Max 2016. and changed Wizard=VsWizard.VsWizardEngine.11.0 not working.

Open the .vcproj created by the wizard and edit the path within to match wherever that file is installed on your machine. A vcproj file is just an XML file, and it seems that for whatever reason the wizard is not putting in the correct path.

1 Reply
 MZ1
(@mz1)
Joined: 11 months ago

Posts: 0

Sorry I had mistake in the wizard “Enter Your MaxSDK Path” section, but now I got new error:

The issue seems pretty obvious from that error. An entry in your vcproj file is “V4.6” when it should be a number, like “4.6”. No idea why that’s happening.

Also worth noting it looks like you need to upgrade your .NET version, if it’s wanting 4.6.1.

I don’t use Max. But I do use a lot of SDK’s. And based on what I see here. You’re probably using the wrong version of VS (The wrong toolset).
According to the online 3Ds Max 2018 help docs. It requires you to have VS2015 with update 3 installed. Not VS2012.
The link to the docs: [ https://help.autodesk.com/view/3DSMAX/2018/ENU/?guid=__developer_about_the_3ds_max_sdk_sdk_requirements_html

According to Microsoft. You can use VS2017 to run an SDK that uses and older version of VS.
So…You first need to install VS2015. And then in VS2017. You might need to set the toolset option to vc14(2015) or something like that. I’ve never done it myself.

Since you’re a C++ newbie.
What I would recommend is skip using VS2017 entirely until you get yourself up and running. And making Max 2018 plugins with VS2015.
I would strongly suggest removing every version of VS from your computer and install only VS2015+update 3. Then try to compile the MAX 2018 SDK.
Once you can do that. THEN…you can think about installing VS2017 and using it.

Good Luck,
-ScottA]( https://help.autodesk.com/view/3DSMAX/2018/ENU/?guid=__developer_about_the_3ds_max_sdk_sdk_requirements_html )

1 Reply
 MZ1
(@mz1)
Joined: 11 months ago

Posts: 0

I’ so lucky that non Max user read this topic :), you right!, I should install desirable VS version. At the moment I just tried VS 2012 and Max 2016 and finally Wizard works! Let say I want to build plugin for Max version 2013 – 2019, how many VS I should install? Is it possible to install toolsets without installing complete IDE? I just searched for 2017 and it seems it has option for installing toolset from VS 2015 Update 3.

Visual Studio is a monster in every sense of the word.
It’s a monster of an IDE with tons of great options. —>Good
It’s a monster in the amount of garbage it installs. —>Bad
It’s a monster in the amount of resources it tales over. —>Bad
It cannot be updated easily to use something compiled with an older version (aka. the toolset) —–> Very BAD!

The answer is no. There is no way to install just the toolset. That would be too logical make too much sense.
So you’ll need to install each version of VS that an SDK was compiled with.
To make it worse. Multiple versions of VS do not always play nice together. Especially the older versions. Microsoft is finally trying to fix that now.
To minimize conflicts. Microsoft recommends to install multiple VS versions from lowest to highest.
This is why developing with C++ is such a pain the **s. They make it harder than it it needs to be.

What you need to do is this:
-Uninstall every single version of VS you have. And try to clean up all the junk you’ve got installed.
If you can format your HD and start fresh without too much effort. That would be the best. Because you’ll never delete everything you’ve installed up to this point manually.
-Look at the SDK’s that you think you’ll want to use. Then install the lowest version of VS first.
You’ll probably never need the VS2008 or VS2010 toolsets.
So based on your usage of MAX2016. I would guess that you would install VS2012 first->Then VS2013->Then VS2015–>Then VS2017.

Welcome the land of C++. Where everything is more painful than it needs to be. And there’s traps everywhere you step.
This is why real men use C++. And everyone else uses Python.

-ScottA

Page 1 / 2