THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/08/2005 at 21:56, xxxxxxxx wrote:
Something must be incorrect somewhere else then. My second message had the correct methodology. Here's a simple test source (MenuPlugin) - it loads an icon, so you may want to dump some tif or jpg image as the one mentioned in main() to avoid complaints. Also, use your own Plugin_ID for PLUGIN_MENU_ID.
This worked perfectly. Calling the plugin from the Plugins menu created a Camera object.
////////////////////////////////////////////////////////////////
// allocobject.cof
////////////////////////////////////////////////////////////////
// Included symbols
//include "c4d_symbols.h"
enum
{
// Unique ids from http://www.plugincafe.com
PLUGIN_MENU_ID = xxxxxxx,
_DUMMY02_
};
var resource;
var plugin_path;
var plugin_icon;
// CLASS: Drop To Floor Menu - Register plugin in menu
class AllocObject_MenuPlugin : MenuPlugin
{
private:
public:
AllocObject_MenuPlugin();
GetID();
GetIcon();
GetName();
GetHelp();
Execute(doc);
}
AllocObject_MenuPlugin::AllocObject_MenuPlugin() { super(); }
AllocObject_MenuPlugin::GetID() { return PLUGIN_MENU_ID; }
AllocObject_MenuPlugin::GetName() { return "AllocObject"; }
AllocObject_MenuPlugin::GetHelp() { return "Help"; }
AllocObject_MenuPlugin::GetIcon() { return plugin_icon; }
AllocObject_MenuPlugin::Execute(doc)
{
StatusSetText("AllocObject");
var camera;
var document;
if (!(camera = AllocObject(Ocamera))) return FALSE;
document = GetActiveDocument();
StatusSetText("");
if (!document->InsertObject(camera, NULL, NULL)) return FALSE;
EventAdd();
return TRUE;
}
// Start of plugin
main()
{
// Load Resource
if (!(plugin_path = GeGetRootFilename())) println("Unable to find plugin!");
plugin_path->RemoveLast();
// Load Icons
var icon_file = plugin_path->GetClone();
icon_file->AddLast("pluginicon.tif");
plugin_icon = new(BaseBitmap,1,1);
plugin_icon->Load(icon_file);
// Register Plugins
Register(AllocObject_MenuPlugin);
}