Hi @Boony2000 thanks a lot for the code sample I can indeed confirm the issue. I will forward this bug to our development team.
Here a workaround by registering an empty icon.
import c4d
TMP_PLUGIN_ID = 1000001
def enhanceMainMenu():
mainMenu = c4d.gui.GetMenuResource("M_EDITOR")
pluginsMenu = c4d.gui.SearchPluginMenuResource()
menu = c4d.BaseContainer()
menu.InsData(c4d.MENURESOURCE_SUBTITLE, "Test Menu")
menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_" + str(TMP_PLUGIN_ID))
mainMenu.InsDataAfter(c4d.MENURESOURCE_STRING, menu, pluginsMenu)
def PluginMessage(id, data):
print "Pluginmessage"
if id==c4d.C4DPL_BUILDMENU:
enhanceMainMenu()
class MenuTest(c4d.plugins.CommandData):
def CreateEmptyBmp(self):
# Create a BaseBitmap
bmp = c4d.bitmaps.BaseBitmap()
# Init this Bitmap with 1 pixel and as 1bit
if bmp.Init(1, 1, 1, c4d.INITBITMAPFLAGS_NONE) != c4d.IMAGERESULT_OK:
return None
# add alpha channel
alphaChannel = bmp.AddChannel(True, False)
# Set alpha
bmp.SetAlphaPixel(alphaChannel, 1, 1, 0)
return bmp
def GetSubContainer(self, doc, submenu) :
# if we don't have already registered an "empty" icon do it
# This work because, the CommandData is not register with an icon, otherwise use another unique ID
if c4d.gui.GetIcon(TMP_PLUGIN_ID) is None:
bmp = self.CreateEmptyBmp()
if not bmp: return True
c4d.gui.RegisterIcon(TMP_PLUGIN_ID, bmp)
menuItems = [["name1"], ["name2", "hasIcon"], ["name3"]]
for i, data in enumerate(menuItems) :
if len(data) > 1:
submenu.SetString(i+1000, data[0] + "&i" + str(c4d.IDM_KEY_NEXT) + "&")
else:
submenu.SetString(i+1000, data[0] + "&i" + str(TMP_PLUGIN_ID) + "&")
return True
if __name__ == "__main__":
c4d.plugins.RegisterCommandPlugin(
TMP_PLUGIN_ID,
"MENU TEST",
c4d.PLUGINFLAG_HIDEPLUGINMENU,
None,
None,
MenuTest())