Main Index :

Plugin types


The C.O.F.F.E.E. language could be ever so good, but it would be rather useless if the code was never executed. There are several ways to connect your plugin code to the C4D interface:

Except for expression tags, the above requires that you deal with one or more external plugin files (for example .cof files). It is recommended that you first read this page about how plugin files and directories should be organized before continuing.

Expression tags

This is the easiest way to add C.O.F.F.E.E. functionality to a scene. The code is written within the C4D app and is stored in the scene file. One can simply add an expression tag and start coding directly. The expression code should contain a main() function:

main(doc, op)
{
  // […]
}

This function is called every time C4D redraws the editor. The first argument is the document that the expression tag is in and the second is the object on which it is placed. Within the main() function you can do whatever you want to the scene. Commonly expression tags are used for simple things, for example controlling the color of a light based on the position of op.

For some more examples of what expression tags can do, please see the C4D CD.

When it comes to writing more complex functions, expression tags are rather limited. For example they cannot have a user interface. If you need such features it's better to use an expression plugin tag.

Menu plugins

Menu plugins add a menu item to the plugin menu in C4D and provide a function that is called whenever the user chooses this menu item. The menu item can be moved by the user to other menus and, provided that an icon is supplied, even be placed on a tool bar.

To create a menu plugin you should inherit a class from MenuPlugin.

Examples: menuplugin.cof, CyclicUVs.cof, MPControl.cof

Filter plugins

Filter plugins extend C4D's import and export capabilities. An example would be a plugin that exported and imported objects in a custom game format. It is not necessary to provide both import and export functions. Export filters will appear in the Export sub-menu of the File menu, while import filters are transparently applied to foreign files opened with the Open command.

To create a filter plugin you should inherit a class from FilterPlugin.

Examples: filterplugin.cof, raw.cof

Plugin tags

Plugin tag plugins do, not surprisingly, add new tags to C4D. Plugin tags are mainly used to store and edit custom data for each object, for example an object's physical properties in a dynamics simulator. It is not necessary for a plugin tag to be visible and have an icon. Invisible tags can be useful to store data without cluttering the user's display.

You can either choose to have you plugin tag added as an entry to the New Tag menu in the Object Manager, or you can choose to add it yourself in an accompanying menu plugin. The latter can be useful if you always need to add several tags at a time, none of which makes any sense alone.

To create a plugin tag plugin you should inherit a class from PluginTag.

Examples: tagplugin.cof

Expression plugin tags

Expression plugin tags are just like plugin tags except that they also provide an Execute() function that is called every redraw. This way you can write expressions with an interface, like the built in target expression for example. The advantage of an expression plugin tag over an animation plugin is mainly that it's easier and faster to add for the user. It is also truly called every redraw.

To create an expression plugin tag you should inherit a class from ExpressionPluginTag.

Examples: expressiontagplugin.cof

Animation plugins

Animation plugins add new keyframable animation tracks to C4D. Just like with plugin tags you can either add the track manually or let C4D add it to its New Track menu. Contrary to the other plugin types, there is not a single AnimationPlugin class to inherit the plugin from. Instead an animation plugin consists of three separate plugin classes:

First there should be a key plugin, inherited from PluginKey. It stores and allows the user to edit key frame values.

Then there should be a sequence plugin, inherited from PluginSequence. This is normally a rather uninteresting class, but it can be used to store custom values.

Finally there should be a track plugin, inherited from PluginTrack. This class should have an Animate() function that is called when the animation plugin should be evaluated.

Important: All of these three classes must be registered with the same plugin id!

Examples: animationplugin.cof