Porting a python command plugin to R21
-
Hey folks,
I am currently porting a command plugin to C4D R21, because some users reported that it is not working for them. However, on a Mac it works on R21 but I get this error message in the console:
Traceback (most recent call last): File "/Applications/Maxon Cinema 4D R21/PLugins/SelectionToObject/SeletionToObject.pyp", line 271, in <module> okyn = plugins.RegisterCommandPlugin(PLUGIN_ID,"Selection to Object",0,bmp,"Selection to Object",SelectionToObject()) RuntimeError:The plugin ID '1054093999' collides with another plugin ID in 'SeletionToObject'. You have to use a unique ID for registering your plugin! You can get a personal number for free from PluginCafe at www.plugincafe.com
I already got a new plugin ID from PluginCafe but it does not solve the problem.
Here is the main function of the plugin, which throws the error:
PLUGIN_ID = 1054093 if __name__=='__main__': bmp=bitmaps.BaseBitmap() path, fn = os.path.split(__file__) bmp.InitWith(os.path.join(path,"res","Icon.tif")) okyn = plugins.RegisterCommandPlugin(PLUGIN_ID,"Selection to Object",0,bmp,"Selection to Object",SelectionToObject()) if (okyn): print "Selection to Object successfully initialized"
Any help would be appreciated. Thank you
-
Hi,
I think the most important question is: What does c4d think is registered under these/this ID(s)? You should run
c4d.plugins.FindPlugin(your_id)
and print the result to the console. Since you said that you have already registered a new ID, I would assume that somehow something else is reading your plugin id constant and using it. Your error message is hinting at that the other registration does seem to come from the same path (SelectionToObject
).Cheers
zipit -
Hi Matthias, thanks for reaching out us.
With regard to the issue reported a few notes:
- since R20 it's possible to install plugins in a different folder than <cinema 4d>/plugins: this makes plugin deployment easy
- since R21 it's possible to use, beside the plugin path definition in the Preference pane, to set the plugin path by using g_additionalmodulepath=<path to the plugin folder> to have Cinema loading specific plugins
As already pointed out by @zipit, the same id is used twice when Cinema 4D pointing to the option that either another plugin is using the same ID or that the plugin is loaded twice because the plugin search path has been messed.
I also confirm that the 1054093 ID is used nowhere in Cinema 4D.Looking forward your comments, give best.
RFinally, it's not recommended to store in locations like user-owned folder, which doesn't require elevated rights to operate in those folders (like instead it's required in the
/Applications
folder) -
The problem is solved. It was so trivial :D. I unchecked the plugins folder which I added in the preferences. My plugins folder was in the C4D directory, so as you described, it was loaded twice.
Leaning for me: Never place a custom plugins folder in the C4D directory!
Recommendation to the SDK team: Maybe you could adjust the error message in the console, which mentions that plugin folders should not be in the C4D directory. I would assume that many users/ devs will place the folder there, because of a habit from older versions.Thank you @r_gigante and @zipit for your quick response!