On 28/08/2018 at 02:32, xxxxxxxx wrote:
Hi there,
i'm failing to get a submenu with a commanddata plugin...
could anybody more experienced maybe have a look at this code?
best, index
my folder structure is:
plugins
Test
test.pyp
icon.png
what i would like to get in the plugin menu is:
Plugins
Test Plugin
Submenu1
Submenu2
but what i get with the following code is just: (no submenu!)
Plugins
Test
import c4d
from c4d import bitmaps
import os.path
PLUGIN_ID = 1234567 # unique ID (obtained from www.plugincafe.com)
PLUGIN_SHORT = "Test Plugin"
MENUID_SUB1 = 1000
MENUID_SUB2 = 1010
class MenuHandler(c4d.plugins.CommandData) :
def Register(self) :
bmp = bitmaps.BaseBitmap()
dir, f = os.path.split(\__file\_\_)
fn = os.path.join(dir, "icon.png")
bmp.InitWith(fn)
return c4d.plugins.RegisterCommandPlugin(
id=PLUGIN_ID,
str=PLUGIN_SHORT,
info=c4d.PLUGINFLAG_COMMAND_HOTKEY,
icon=bmp,
help="",
dat=self
)
def GetSubContainer(self, doc, submenu) :
bc = c4d.BaseContainer()
bc.SetString(1, PLUGIN_SHORT)
bc.SetString(MENUID_SUB1, "Submenu1")
bc.SetString(MENUID_SUB2, "Submenu2")
submenu.InsData(0, bc)
return True
def ExecuteSubID(self, doc, id) :
if id == MENUID_SUB1: print "Submenu1"
elif id == MENUID_SUB2: print "Submenu2"
return True
def Execute(self, doc) :
return True
if __name__ == "__main__":
MenuHandler().Register()