On 21/08/2014 at 12:50, xxxxxxxx wrote:
Hello,
the structure of a python tag plugin is pretty much like the structure of any other plugin.
First you have the actual python plugin source file:
import os
import math
import c4d
from c4d import plugins, bitmaps, utils
class ExamplePythonTag(plugins.TagData) :
def Init(self, node) :
# init your plugin here
return True
def Execute(self, tag, doc, op, bt, priority, flags) :
# execute the plugin here
return c4d.EXECUTIONRESULT_OK
if __name__=='__main__':
plugins.RegisterTagPlugin(id=1027090, str="Example Tag",info=c4d.TAG_EXPRESSION|c4d.TAG_VISIBLE, g=ExamplePythonTag, description="Tpythontag", icon=bitmaps.BaseBitmap())
What you also need is three other files. First the description resource "Tpythontag.res" in the res\description folder. The resource file let's you define the (fixed) parameters of your plugin:
CONTAINER Tpythontag
{
NAME Tpythontag;
// add your parameters here
}
Beside the resource file you have to add a "Tpythontag.h" that defines the IDs for each parameter within a enumeration:
#ifndef _Tpythontag_H_
#define _Tpythontag_H_
enum
{
// add your parameters here
}
#endif
Finally you need to define your string. This is done in the "Tpythontag.str" file in res\strings_us\description:
STRINGTABLE Tpythontag
{
Tpythontag "Example Python Tag";
}
Every plugin also needs a "c4d_symbols.h" in the res folder. There you can define IDs for global strings. These strings can be defined in "c4d_strings.str" in the "strings_us" folder.
You find an overview over python plugin structure in the SDK, where you also find an example tag plugin.
Best wishes,
Sebastian