Development for Microsoft Windows

Requirements

Note
It is recommended to always use the latest version of the given Visual Studio release.

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

  • Cinema 4D S22 SDK : Visual Studio 2019
  • Cinema 4D R21 SDK : Visual Studio 2017**
  • 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.

(**)The Cinema 4D R21.0 SDK (fixed in Cinema 4D R21.1 SDK) enables Advanced Vector Extensions (AVX) support by default. To disable AVX support, remove the corresponding line from the frameworks\settings\Base.props file:

<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>

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
Note
An addtional #undef COMPONENT may be needed, depending on the Windows header files involved. This will be added to the undef_win_macros.h header in a later release.

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\vs17\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.

Cinema 4D can be informed on the type of license model to use - which can be helpful in certain automated tasks - by using:

  • g_licenseServerRLM="[servername]:[port]" to specify the RLM license server, or
  • g_licenseServerURL="[http(s)://[ip address]:[port]" to specify the Maxon license server, or
  • g_licenseUsername and g_licensePassword to specify the authentication credentials on https://id.maxon.net.

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.

Note
Make sure your plugin includes all needed dependecies including Microsoft Visual C++ redistributables. Redistributables installed with Cinema 4D change with every release.

Further Reading

C4D
C4D
Definition: lib_net.h:673
undef_win_macros.h
OSX
OSX
OS X.
Definition: ge_prepass.h:3346