On 08/01/2018 at 07:36, xxxxxxxx wrote:
I have an Object Generator plugin that has an only one button.
I want to perform some operations when pressing it.
For example, create a sphere and insert it under Object Generator plugin...
Here is how my code looks like, but it's not working...
import c4d
from c4d import plugins, utils
import os
TESTPLUGIN_ID = 1040447
TESTPLUGIN_VALUE = 1000
class Testplugin(c4d.plugins.ObjectData) :
def Message(self, node, type, data) :
if type == c4d.MSG_DESCRIPTION_COMMAND:
if data["id"][0].id == TESTPLUGIN_VALUE:
sphere = c4d.BaseObject(c4d.Osphere)
sphere.InsertUnder(node)
return True
if __name__ == "__main__":
bmp = c4d.bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
fn = os.path.join(dir, "res", "icon.tif")
bmp.InitWith(fn)
result = plugins.RegisterObjectPlugin(
id = TESTPLUGIN_ID,
str = "Test Plugin",
g = Testplugin,
description =
"Otestplugin",
info = c4d.OBJECT_GENERATOR,
icon = bmp)