home
portfolio
services
notebook
links
This way out

 

 

 

CINEMA 4D, Revision 6

 

COFFEE plugin tutorial
The nuts and bolts of a plugin

 

(a link will be available to part 8 of this tutorial soon)

coffee tutorial 1:  Introduction
coffee tutorial 2:  Programming basics
coffee tutorial 3:  The nuts and bolts of a plugin
coffee tutorial 4:  Your first dialog box
coffee tutorial 5:  A better dialog box
coffee tutorial 6:  Creating a house object
coffee tutorial 7:  Interactive house modeling
coffee tutorial 8:  International resources

 

 

For QuickStarters:

* copy and paste the listing text (below) to a simple text editor and save it as a plain text file under the name 'lesson3.cof' into the C4D "plugins" folder.

* restart c4d (or use the menu command "Reload Plugins")

* Open the window "Console"

* execute the plugin-menu command "coffee-lesson-3"

* the console shows the word "Hello"


The Listing:


const var cPluginID = 2000001;
class oMenuPlugin : MenuPlugin
{ public:
oMenuPlugin();
GetID();
GetName();
GetHelp();
Execute(doc);
}
oMenuPlugin::oMenuPlugin() { super(); }
oMenuPlugin::GetID() { return cPluginID; }
oMenuPlugin::GetName() { return "coffee-lesson-3"; }
oMenuPlugin::GetHelp() { return "Writes Hello in the console"; }
oMenuPlugin::Execute(doc) { println("Hello"); }
main()
{ Register(oMenuPlugin);
}

 

The Explanation:


main is the main program

Main is executed once when the Plugins are being loaded. This happens when C4D is started and also with the "Reload Plugins"-command in the "console"-window. We register our object (here: oMenuPlugin) in this main.


class oMenuPlugin : MenuPlugin

MenuPlugin is a class (of C4D), a collection of functions. Our class (oMenuPlugin) will be constructed from this class. All functions that should work after our rules overwrite the standard functions. Additional functions (which do not apply here) will attend our class. MenuPlugin owns more functions, but these 5 are the bottom limit. If c4d misses just one of them while loading, it is claimed by c4d it in the console-window.


oMenuPlugin::oMenuPlugin()

signs our class. Don't bother, that's the way it has to be.


oMenuPlugin::GetID()

Equally a function which can be taken over everytime and unchanged in order to hand the plugin ID number over. Every PlugIn needs a unique number before being distributed.


oMenuPlugin::GetName()

This is a menu-plugin. The text declared here ('coffee-lesson-3' in this case) forms the name of the C4D plugin menu entry. If the xxx.cof-file resides as the only file in a sub-folder of the Plugin-folder, it will appear directly in the menu. If there are more than one xxx.cof's, a submenu with the name of the sub-folder will be created automatically.


oMenuPlugin::GetHelp()

This text will be shown in the C4D status-bar when the mouse-cursor is moved over the menu-entry.


oMenuPlugin::Execute(doc)

Let's get it working ;-) When the menu-command is executed, this extremely useful function writes a "Hello" (or whatever you have programmed) into the console-window.

----------------------------------------
Text copyright © H. G. Seib 2000, HTML copyright © M. D. Abbott 2001

 

 


Vantage Graphics and Design Limited
9 Vicarage Lane, Harbury, LEAMINGTON SPA, Warwickshire CV33 9HA, UNITED KINGDOM
Telephone: 01926 614211 Fax: 01926 614226 ISDN: 01926 614210
E-mail: studio@vgd.co.uk

Page last updated: 05 July 2001