Development for Microsoft Windows

Requirements

Plugin development on Microsoft Windows is only supported with Microsoft Visual Studio. The supported versions are:

  • Cinema 4D R20 SDK : Visual Studio 2015*
  • Cinema 4D R19 SDK : Visual Studio 2015
  • Cinema 4D R18 SDK : Visual Studio 2013
  • Cinema 4D R17 SDK : Visual Studio 2013
  • Cinema 4D R16 SDK : Visual Studio 2012
  • Cinema 4D R15 SDK : Visual Studio 2012
  • Cinema 4D R14 SDK : Visual Studio 2010
  • Cinema 4D R13 SDK : Visual Studio 2005

(*)Using Visual Studio 2017 for Cinema 4D R20 SDK is only supported on Windows 10. The project files must be adapted manually.

Development Environment

The SDK includes Natvis files for several data types. The files are:

  • frameworks\core.framework\project\typeviewer\msvc\maxon.natvis
  • frameworks\cinema.framework\project\typeviewer\msvc\c4dapi.natvis

The files can simply be copied to the local "Documents\\Visual Studio 2015\\Visualizers" folder.

Alternatively, it is possible to include the Natvis files in a solution using AdditionalSolutionFiles:

// Configuration of a custom solution in the projectdefinition.txt file
// support Windows and macOS
Platform=Win64;OSX
// this is a solution
Type=Solution
// included plugin projects
Solution=\
plugins/pluginA;\
plugins/pluginB
// include natvis files in Visual Studio solution file
AdditionalSolutionFiles=\
..\..\frameworks\core.framework\project\typeviewer\msvc\maxon.natvis;\
..\..\frameworks\cinema.framework\project\typeviewer\msvc\c4dapi.natvis

Best Practice

Windows Specific Code

Windows specific code can be guarded with the macro MAXON_TARGET_WINDOWS:

#ifdef MAXON_TARGET_WINDOWS
#endif

Windows Includes

If a source code file includes Windows header files it must also include undef_win_macros.h to un-define certain macros.

#ifdef MAXON_TARGET_WINDOWS
#include <wtypes.h>
#endif

Running Plugins

It is possible to start Cinema 4D from Visual Studio to run and debug a plugin:

  • Mark one plugin project in the solution as "Startup Project".
  • In this project's properties set "Debugging" -> "Command" to the location of a compatible Cinema 4D executable.

The Cinema 4D executable must find the compiled plugins. The plugin location can be set with the g_additionalModulePath command line argument. One can also use "$(ProjectDir)..\.." instead of the absolute path.

Additional command line arguments can be set (e.g. to run unit tests). See Unit Tests Manual and Configuration Variables.

Debugging

The Output console displays messages printed with DiagnosticOutput(). See Debug and Output Functions.

For general information on debugging see Debugging.

Automating Processes

The execution of the Project Tool can easily be automated using Windows batch files.

This batch file executes the Project Tool on the given location of the SDK and starts Visual Studio to open the solution file:

REM Build SDK
CD /D C:\development\project_tool
kernel_app_64bit.exe g_updateproject=C:/development/sdk_extracted
CD /D C:\programs\vs14\Common7\IDE
devenv.exe C:\development\sdk_extracted\plugins\project\plugins.sln

This batch file starts Cinema 4D with the location of the plugins:

REM run C4D
CD /D C:\programs\cinema_4d
"CINEMA 4D.exe" g_additionalModulePath=C:\development\sdk_extracted\plugins

Additionally one can set the command line argument g_runUnitTests to automatically execute custom unit tests.

DLLs

DLLs needed by a plugin can be placed in myplugin\res\libs\win64.

Deployment

The final plugin build for deployment should be created using the "Release" build target.

Further Reading