On 01/07/2018 at 08:05, xxxxxxxx wrote:
Hi,
It's been a while ago since I last made some Python plugin/script.
I was playing around with the Object Manager's menu and wanted to add an entry, right after the "Scroll to first active object".
I have been able to add it to the end of the "View" menu, but not right at the desired location.
Haven't tried it in C++ as I am kind of prototyping this in Python first.
Now, I suppose I need to use BaseContainer.InsDataAfter
( id , n , last ) but the "last" is troubling me. I thought of needing to use BaseContainer.GetDataPointer
( id ), which has been made available since R17.053 but cannot seem to find out what the "id" is I need to pass.
import c4d
def main() :
omMenu = c4d.gui.GetMenuResource("M_OBJECT_MANAGER")
for index, menu in omMenu:
if index == c4d.MENURESOURCE_SUBMENU:
subtitle = menu.GetString(c4d.MENURESOURCE_SUBTITLE)
for idx, submenu in menu:
if idx == c4d.MENURESOURCE_COMMAND and submenu == "PLUGIN_CMD_100004769":
# found
# how to obtain the found entry as a pointer, in order to add a menu entry right after it ?
target = ????
menu.InsDataAfter(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_1041359", target)
c4d.gui.UpdateMenus()
break;
if __name__=='__main__':
main()