On 14/11/2016 at 08:37, xxxxxxxx wrote:
Hi again,
Working on a plugin I assumed that InitDefaultSettings would be called each time the python plugins are reloaded.
For now, the method is only called the first time the plugin is activated after starting Cinema4D, and only the first time you perform "reload python plugins" after Cinema4D has started.
Any subsequent "reload python plugins" just simply doesn't call the InitDefaultSettings.
Is this as intended?
Below is a simplified plugin which shows this behaviour.
import c4d
import os
from c4d import gui, plugins, bitmaps, utils
PLUGIN_ID = 1031001 # dummy ID
class Testing(plugins.ToolData) :
def __init__(self) :
print "__init__"
return
def InitDefaultSettings(self, doc, data) :
print "InitDefaultSettings"
return
def InitTool(self, doc, data, bt) :
print "InitTool"
return True
def FreeTool(self, doc, data) :
print "FreeTool"
return
def Message(self, doc, data, type, t_data) :
return True
# =============== Main =============
def PluginMain() :
try:
bmp = bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
fn = os.path.join(dir, "res", "Testing.tif")
bmp.InitWith(fn)
plugins.RegisterToolPlugin(id=PLUGIN_ID, str="Testing",
info=0,
icon=bmp,
help="Testing",
dat=Testing())
except TypeError:
# when performing a 'reload plugin' without the plugin being registered to the system yet
# -> user should restart Cinema 4D
print "Unable to load plugin (Testing)"
if __name__ == "__main__":
PluginMain()