@ferdinand
Ok, I can now insert my command in the render Tab, but it is positioned at the end.
This is, I guess, because I use InsData() instead of InsDataAfter()
Refering to my first code, this was my thinking:
When using InsDataAfter(), looking at the documentation, I thought that last(any) indicates the position after where to insert the command. That is why I used sub.
So, how to indicate where to insert the command?
BaseContainer.InsDataAfter(self, id, n, last)¶
Inserts an arbitrary data at the specified id after last.
Warning This function does not check if the ID already exists in the container!
Parameters
id (int) – The ID to insert at.
n (any) – The data to insert.
last (any) – The data to insert after.
Working code that inserts the command at the end.
from typing import Optional
import c4d
pluginId = "1052844" # official plugin ID
def main() -> None:
MainMenu = c4d.gui.GetMenuResource("M_EDITOR")
for bcMenuId, bcMenu in MainMenu:
#print (bcMenu[c4d.MENURESOURCE_SUBTITLE])
if bcMenu[c4d.MENURESOURCE_SUBTITLE] == "IDS_EDITOR_RENDER":
for sub in bcMenu:
if (sub[1] == "IDM_RENDERAUSSCHNITT"):
print ("*** Insert after this ***")
# Add my plugin
#bcMenu.InsDataAfter(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_5159", sub)
bcMenu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_" + pluginId)
c4d.gui.UpdateMenus()
if __name__ == '__main__':
main()