Hello @alexandre-dj,
I know all menus in C4D have their own id, so this should be an easy check.
That is only true on a relatively abstract level. There are string symbols, e.g., IDS_EDITOR_PLUGINS for menu resources, but there is no strict namespace management or anything else on might associate with statements such as 'all menus in C4D have their own id'. Also note that all menu entries in a menu container are stored under the integer IDs MENURESOURCE_COMMAND and MENURESOURCE_SUBMENU as shown in my example above. So, when you have a menu with ten commands and four sub-menus, all fourteen items are stored under these two IDs. This works because BaseContainer is actually not a hash map as one might think, and can store more than one value under a key.
Long story short - traversing and modifying menus is not ultra complicated but I would also not label it as 'easy' ; which is why I did provide the example in my previous posting.
When firing c4d.gui.GetMenuResource("M_EDITOR") to Get the whole menu of Cinema 4D (as you mention in your code here) I get a different address every time:
>>> c4d.gui.GetMenuResource("M_EDITOR")
<c4d.BaseContainer object at 0x000001B406C86580>
>>> c4d.gui.GetMenuResource("M_EDITOR")
<c4d.BaseContainer object at 0x000001B406CA6A40>
>>> c4d.gui.GetMenuResource("M_EDITOR")
<c4d.BaseContainer object at 0x000001B406C88C80>
You are calling here the Python layer for returning a Python object representation of the C++ object that represents the menu. Cinema 4D is still a C++ application and the menu exists in your memory with the layout defined by the C++ type BaseContainer. That type has memory-wise nothing to do with its Python counter part c4d.BaseContainer.
So, the Python layer must create that Python data on the fly, as otherwise the memory-footprint of Cinema 4D would double (actually more, because Python data is not exactly sparse data) and synchronizing both data layers would bring Cinema 4D to a crawl. TLDR; you retrieve the same data expressed as a different memory object because 'that is how Python works'.
So when I use c4d.gui.SearchMenuResource(main_menu_ressource, my_custom_menu) to check if my custom menu is part of the main menu, this always return False, as the address of the main_menu object changes.
Why your call fails here, depends a bit on what you are passing. The first argument should be the string symbol inside a sub menu, and the second item is the sub menu. When you store a reference to a sub-menu from a previous call to GetMenuResource, this might not work when SearchPluginMenuResource searches by identity instead of equality, i.e., it expects that container to be at a certain memory location (have not tried though). There is also c4d.gui.SearchPluginMenuResource(identifier='IDS_EDITOR_PLUGINS'), which should be sufficient to find anything that does not produce a name collision. I personally would just write my own stuff as demonstrated above, since I can then search however I want to.
Cheers,
Ferdinand