Creating a new plugin project in Visual Studio

by .

For the newbies among our fellow readers, here is a complete step by step walkthrough for creating a new plugin project in Microsoft Visual Studio. The screenshots show Visual Studio 2005, but it still works exactly the same way in Visual Studio 2010.

Basic project setup

You start with just the standard folder structure, containing a “res” folder with your symbols, icons, and string tables, and a “source” folder, containing your C++ Sources (subfolders are – of course – possible).

Take a look into the “cinema4dsdk” folder and locate the project file and the properties file.

Copy & paste these two files into your plugin’s folder.

Rename the project file as you wish, using the title of your plugin might be a good idea.

Open the project in Visual Studio

Change the project title. This will also determine the filename of the plugin binaries.

Select all of the SDK source files that are still in the project…

…and remove them by pressing the “Del” key.

Drag & drop your source files (including subfolders) into the “Source Code” in your project.

Right-click on the solution, and from the context menu choose “Add -> Existing Project…”

Now add the CINEMA 4D API project to your solution. Navigate to “CINEMA 4D/resource/_api_lib” and choose the “_api” project file.

You must also make your project dependent from the CINEMA 4D API. Right-click on your project (not on the solution) and choose “Project Dependencies…”

Make sure that “_api” is enabled.

Additional include paths

If there are any additional include directories where you have stored header files, you must add them to the project’s header search paths. Open the project settings by right-clicking on the project on top of your tree and choosing “Properties”.
Navigate to “Configuration Properties” -> “C/C++” -> “General”. Also make sure that, on top of the dialog, your have selected “All Configurations” and “All Platforms”. This will apply your changes to all build configurations for all platforms, and save you the work for applying a change to each combination separately.
Select the “Additional Include Directories” and click the little “…” icon on the right side. A dialog will pop up. You can add any path here, absolute ones as well as paths relative to your project location.

From the File menu, choose “Save All”.

The Save dialog will come up, asking you to save the solution. By default, the suggested location will be the one of your project file, and the filename will also be the one of your project file. There is no reason to change that.

That was already it, you’re done.
Start a full rebuild and see if your code compiles fine.

Setting up a debug session

Even if your project compiles fine, there might still be bugs which you’ll have to address. To do that, you will want to start a debug session with CINEMA 4D.
To set up your project for a debug session, open the project properties again and locate the entry “Debugging” in the tree on the left side. On the right side, in the “Command” entry, click the little “…” icon and select the CINEMA 4D.exe.
Note: As long as you don’t experience any issues that only occur in a 64 Bit build, you will want to use the 32 Bit build for debugging. That is, because Visual Studio only supports the “Edit and Continue” (pausing the execution, changing your code, and then continuing execution) functionality for 32 Bit. With a 64 Bit build, you will always have to stop execution, then build your project again, and then restart CINEMA 4D.

To start a debug session, click the “Play” button in the toolbar, or press F5.