On 18/06/2018 at 08:35, xxxxxxxx wrote:
Hi folks,
Recently, I tried to create my first Python plug-in, and I was troubled by a problem for a long time.
Console: RuntimeError: Could not initialize global resource for the plugin.
I search a lot in the SDK document and forum, but I still don't know how to solve it. I hope can get your help. Here's my test code:
(test.pyp)
_____
import c4d
import sys
import os
from c4d import plugins,bitmaps
PLUGIN_ID = 1000001
OBJECTGROUP = 1001
OBJECT = 1002
MAP = 1003
class test(plugins.ObjectData) :
def __init__(self) :
self.SetOptimizeCache(True)
def ModifyObject(self, mod, doc, op, op_mg, mod_mg, lod, flags, thread) :
op.SetPoint(0,c4d.Vector())
op.Message(c4d.MSG_UPDATE)
return True
if __name__ == "__main__":
bmp = bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
bitmapfile = os.path.join(dir, "res", "Icon.tif")
result = bmp.InitWith(bitmapfile)
plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="test",g=test,description="test",icon=bmp,info=c4d.OBJECT_MODIFIER)
___
(test.h)
__
#ifndef _Oatom_H_
#define _Oatom_H_
enum
{
OBJECTGROUP = 1001,
OBJECT = 1002,
MAP = 1003,
};
#endif
__
(test.res)
__
CONTAINER test
{
NAME test;
INCLUDE Obase;
GROUP OBJECTGROUP
{
LINK OBJECT {}
LINK MAP {}
}
}
__
(test.str)
__
STRINGTABLE test
{
OBJECTGROUP "List";
OBJECT "obj"
MAP "map";
}