THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/02/2003 at 02:01, xxxxxxxx wrote:
ok, here is the way to our first real plugin.
Marcus, thanks again to provide me with the code and additional information.
There is one thing I didn't change, but I think it's better to change it in future.
You stored the PluginID in c4d_symbols.h. This file must be distributed to the end user
and therefore every end-user can change it. This might help during development, but I don't
think that anybody should be able to change a unique PluginID given to the author.
so, the first thing we need is a plan what we're going to do.
It's an easy plugin so we don't need a big plan:
Plugin to send a Hello World message box and write some info into console
here are the steps to do this:
- create a subfolder Hello2 under "MyPlugins"
- copy our empty project to Hello2 and rename it like describe above
- create necessary subfolders in project and file system
- res
- strings_de
- strings_us
- ..... (whatever strings_lang you want)
- src
good.
now we need some files.
-
create a new file in "res" folder called "c4d_symbols.h" and fill in this code:
enum
{
IDS_PLUGIN_NAME = 0,
IDS_PLUGIN_DESCR,
IDS_MESSAGE,
IDS_ERR_CONSTR,
PLUGIN_ID = 1009173
};
-
create a new file in "strings_us" folder called "c4d_strings.str" and fill in this code
STRINGTABLE
{
IDS_PLUGIN_NAME "Hello World Advanced ;)";
IDS_PLUGIN_DESCR "Prints out a Hello World message";
IDS_MESSAGE "Hello World!";
IDS_ERR_CONSTR "Construction of HelloWorld object failed";
}
-
if you like to you can create additional files in the language folders. example for "strings_de":
create a file called "c4d_strings.str" and fill in:
STRINGTABLE
{
IDS_PLUGIN_NAME "Hallo Welt Erweitert ;)";
IDS_PLUGIN_DESCR "Gibt eine 'Hallo Welt'-Nachricht aus";
IDS_MESSAGE "Hallo Welt!";
IDS_ERR_CONSTR "Es konnte kein HelloWorld-Objekt erzeugt werden";
}
-
and now the very important plugin code itself. Create a new file in "src" folder called "Hello2.cpp"
and fill in:
#include "c4d.h"
#include "c4d_symbols.h"
/**
*
*/
class HelloWorld : public CommandData
{
public:
virtual Bool Execute(BaseDocument* doc);
};
///
Bool HelloWorld::Execute (BaseDocument* doc)
{
String wind0 = "Windows";
GeOutString (GeLoadString (IDS_MESSAGE), GEMB_OKCANCEL);
GePrint ("Hello World Advanced :))))))");
if (GeGetCurrentOS() == GE_WIN){
GePrint ("Hello World "+wind0);
}
else {
GePrint ("Hello World Mac :))))))");
}
return (TRUE);
}
/**
*
*/
Bool PluginStart ()
{
HelloWorld *helloWorld = NULL;
// initialize global resource object
if (!resource.Init()) return FALSE;
// create new instance of HelloWorld class, if not done already
if ((helloWorld = new HelloWorld) == NULL) {
GePrint (GeLoadString (IDS_PLUGIN_NAME) + ": " + GeLoadString (IDS_ERR_CONSTR));
return (FALSE);
}
// register hook and return
return (RegisterCommandPlugin (PLUGIN_ID, GeLoadString (IDS_PLUGIN_NAME),
0, GeLoadString (IDS_PLUGIN_DESCR), helloWorld));
}
/**
*
*/
void PluginEnd ()
{
}
/**
*
*/
Bool PluginMessage(LONG id, void* data)
{
return (FALSE);
}
----------------------------
compile it and if error free start cinema. Open Menu/Plugins/Hello World Advanced (or similar depending on your language settings).
A dialog box appears with our "Hello World" message. Open the console window and see the additional info.
The next time we'll try to describe some background information how plugins work. Marcus supplied me with some html pages I'd like to publish.
No this time no download! Do your homework ;o).
good luck,
Sneaker