Cinema 4D - my C++ plugins

From NoskeWiki
Revision as of 02:22, 6 February 2019 by NoskeWiki (talk | contribs) (Created page with "==About== {{DaughterPage|mother=Cinema 4D}} This page is contains copy of the source code for a few of the C++ plugins I've written for Cinema 4D. The following source c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About

NOTE: This page is a daughter page of: Cinema 4D


This page is contains copy of the source code for a few of the C++ plugins I've written for Cinema 4D. The following source code should work for C4D R12 and later, but won't work for earlier versions. Before attempting to compile any of this code make sure you read Cinema 4D - C++ plugins. To get this code compiling successfully you will need to create a "main.cpp", edit it if necessary and setup the directory structure as follows:

  • CINEMA 4D RXX/plugins/cplusfiles/
    • main.cpp
    • addtext/addtextdialog.cpp
    • fade/fade.cpp
    • find&rename/finddiaplog.cpp
    • objectconverter/objectconverter.cpp

NOTE: In the examples here I have used XCode on a Mac: if you use Windows I'd recommend using Microsoft Visual Studio.


Building a new set of C plugins

  • In the main plugins folder: create a new folder called "cplusfiles" (ie: /Applications/MAXON/CINEMA 4D R12/plugins/cplusfiles)
  • Copy and rename cinema4dsdk/cinema4dsdk.xcodeproj to cplusfiles/cplusfiles.xcodeproj
  • Create a "source" folder and copy cinema4dsdk/source/main.cpp to cplusfiles/source/main.cpp
  • Open mycplugin.xcodeproj and notice almost all the source files listed are red (since they are now broken links). Delete all these red files, so you are just left with "main.cpp" and the dependencies "_api.xcodeproj", "_api.debug.xcconfig" and "_api.release.xcconfig". NOTE: You can also expand "source" on the left and delete all the sub-folders but not essential.
  • Select Project > Edit Project Settings > Build scroll down, change the "product name" to "mycplugins".
  • Open main.cpp (double click) and enter this code (deleting whatever was there before):

main.cpp

//------------------
//-- FILE:    main.cpp
//-- AUTHORS: Andrew Noske
//--
//-- This file is used to register a series of Cinema 4D menu plugins /
//-- CommandData classes when C4D starts
//-- 
//-- For more information see: http://www.andrewnoske.com/wiki/index.php?title=Cinema_4D


//########################################
//-- Includes and Forward Declarations:

#include "c4d.h"

Bool RegisterFadeDialog(void);
Bool RegisterFindDialog(void);
Bool RegisterAddTextDialog(void);
Bool RegisterObjectConverterDialog(void);

//########################################
//-- C4D Hooks:

Bool PluginStart(void)
{
  if (!RegisterFadeDialog())      return FALSE;
  if (!RegisterFindDialog())      return FALSE;
  if (!RegisterAddTextDialog())   return FALSE;
  if (!RegisterObjectConverterDialog())    return FALSE;
  return TRUE;
}

void PluginEnd(void)
{
}

Bool PluginMessage(LONG id, void *data)
{
}


List of my C++ Plugins

addtext.cpp

fade.cpp

findialog.cpp

objectconverter.cpp


Compiling

  • Hit build
  • Restart C4D and click: Plugins > Cplusfiles to see the plugins appear.
  • To see your GePrint() output you will need to open the Console [Shift+F10]. This Console is also useful because you can drag-and-drop labels from the Attributes manager into the Console's command line to see the label's ID.


Code license
For all of the code on my site... if there are specific instruction or licence comments please leave them in. If you copy my code with minimum modifications to another webpage, or into any code other people will see I would love an acknowledgment to my site.... otherwise, the license for this code is more-or-less WTFPL (do what you want)! If only copying <20 lines, then don't bother. That said - if you'd like to add a web-link to my site www.andrewnoske.com or (better yet) the specific page with code, that's a really sweet gestures! Links to the page may be useful to yourself or your users and helps increase traffic to my site. Hope my code is useful! :)



See Also