On 27/07/2016 at 18:11, xxxxxxxx wrote:
I am wanting to create a custom C4D editor menu dropdown with some of our studio's tools. My approach (with some help from these forums) is to edit the MENU_EDITOR, on boot through a small python plugin which is evaluated when Cinema launches. This is easy enough, and can be seen below.
I know this is probably a dodgy technique and the plugin is not exactly orthodox (not properly registered etc.), but I only need it to run once on boot, entirely transparent to the user. (I initally tried the python_init.py file, but quickly found this limiting as is runs prior to GUI elements being called, so I couldn't make changes to the menu and refresh it correctly.)
"""A small plugin which loads additional scripts and tools to a custom menu dropdown"""
from c4d import gui, plugins, utils, bitmaps, storage
import collections, os
PLUGIN_ID = 1987654321234 #testing
def append_menu() :
editorMenu = c4d.gui.GetMenuResource("M_EDITOR")
menu = c4d.BaseContainer()
menu.InsData(c4d.MENURESOURCE_SUBTITLE, "Custom Menu")
menu.InsData(c4d.MENURESOURCE_SEPERATOR, True); # Add a separator
def PluginMessage(id, data) :
if id == c4d.C4DPL_BUILDMENU:
So my question is: now that this 'works', my problem is trying to reliably call various custom scripts, across everyone's machine. It is my understanding that you DO NOT register python scripts, and instead cinema does this for you automatically making it difficult to identify it's PLUGIN_CMD_ID as shown above.
I'd like a way to identify simple scripts, can I register them?
On 28/07/2016 at 01:54, xxxxxxxx wrote:
the ID of a script is created dynamically every time Cinema starts. It is not possible to give a script a fixed ID. Only plugins do have a fixed ID. So you could implement your scripts as CommandData plugins with fixed Ids.
Another way could be to identify your scripts not by ID but by name. Internally Cinema will create a dynamic CommandData plugin for each script. You can loop through all plugins with FilterPluginList(). Then you can compare the name of every plugin with the name of your script. So you can identify the plugin that represents your script and get the ID with BasePlugin.GetID() to construct the string needed four your menu.