How to setup Cinema4D and Melange C++ SDK

Antoine Fortin
5 min readOct 29, 2018

--

Chance are, if you are working with the C4D files, you might want to use their awesome(very actually) Melange SDK. Melange can be used to read and write into .C4D files and allow developer to get infos from a scene in the software and get back infos on lights, camera, mesh, geometry and so on. The tool can be very powerful, notably when it comes to pimp or handle custom pipeline workflow.

If you are interested in using C4D Melange, well, you might have face the lack of documentation to get things up and running. The documentation is very well done, but getting the thing up and running can be a pain in the neck, and it should not be!

In this post, I will walk you to setting up a development environment for using Melange SDK using Windows and Visual Studio 2015. It will be easy as a walk in the park and you will be all good to go at the end of your reading.

It’s a go!

Start by downloading the Melange SDK,

Once downloaded, let’s place it to the C: drive root, this way we can have a better understanding of what is going on! But please also note that you can place it anywhere.

Once extracted in a folder, you will see those files and folder. You are now ready to go to setup the project in Visual Studio 2015 (or any other version.)

Part 2.1: Visual Studio Setup

Well here comes the fun of using Melange SDK, actually using C++ code the talk directly with the C4D file format. Before starting to tweak, we have a little more pain to fix, and it’s actually setting up the SDK in a project.

For the needs of this post, I will start with an empty and fresh VS15 new project.

And leave all theses settings as they are, or fit them to your needs. Depending on what you are using the Melange SDK for.

In your solution explorer, open your main file and place this code into it.

#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
return 0;
}

The next step is to add the C++ libraries to your project. For doing this, simply go to your project Properties. Right click on your project solution and click “Properties” or simply click Alt+Enter

Press Alt+Enter when Project is highlighted.

Once open, go to C/C++ section and click on Additionnal Include Directories

Make sure that your Configuration platform is x64, if not, you will have compiling error later on. You will now include those Include from the Melange SDK we downloaded earlier on.

And from now, you will be able to select any folder on your Drive. We have put the Melange on our C: drive, we can now include it in our project by going in the browser to select it.

Add the Includes from the Melange SDK to your project by Selecting the folder.

Once added, you will see that your project properties now have the following settings.

Part 2.2: Setting up the Linker

In your project configurations, go to Linker/General and select Additional Library Directories

Same as earlier, but now you have to select two(2) items

Go to C:\melangeSDK\libraries\win

We need to add the those two in our project. Please note that for another version of Visual Studio just trade the 2015 for 2013 or Vice and Versa.

And now you should have those in your project:

Then we need one little last step, that might look a bit strange, but somehow work (any other / better workaround would be appreciated.).

We will need to set our Linker Input additional dependencies manually to hard coded C:/PathToSomething.

We need two files:

  • melangelib_release.lib and jpeglib_release.lib

Those two files sits in the folder according to the version of Visual Studio you are using so in my case… Both path are

C:\melangeSDK\libraries\win\jpeglib_2015\jpeglib_release.lib
C:\melangeSDK\libraries\win\melangelib_2015\melangelib_release.lib
winmm.lib
IE: for melangelib_2015.lib file

Do not forget to add the winmm.lib too :)

Part 3: Let’s start coding!

So from now, you have everything to start using the SDK and code. In your main file, the one that contains the main function, you need to include some files, and setting namespace.

Let’s put this code inside your main file.

The two main include header files are

c4d_file.h and default_alien_overload.h, and using the namespace melange. Plus you need to call the void function GetWriterInfo()

#include <iostream> #include "c4d_file.h"#include "default_alien_overloads.h"using namespace melange;using namespace std;void GetWriterInfo(Int32 &id, String &appname){    id = 5148438484;
appname = "This awesome Melange For medium";
}int main(){ return 0;}

After including those, you will be able to compiled and if everything is good you will see this in your console. Compile using x64.

You now have the .exe working.

--

--

Antoine Fortin

In between Montreal and London, I love to write, read, learn and explore.