Hi,
I hadn't any problems regarding your problem. At least in my understanding of it. Below you will find an example for two CommandData
plugins, where one does reference the other in the dialog it displays. Feel free to ask further questions if anything remains unclear ;)
PS: I ran this on R23 and R21 Win. I know from your screenshots that you are on Win (if I am not mixing something up here), but please add OS tags and version tags in the future, as they can be important.
Cheers,
Ferdinand
"""Demonstrates the usage of icons in a dialog menu.
"""
import c4d
# Please use unique plugin IDs obtained from PluginCafe.com.
ID_CMD_ICON = 1053528
ID_CMD_MENU = 1053529
class IconMenueDialog(c4d.gui.GeDialog):
"""The dialog opend by MenuCommandData.
References IconCommandData in its menu.
"""
def CreateLayout(self):
"""Creates the menu of the dialog.
"""
self.MenuFlushAll()
self.MenuSubBegin("Stuff")
# You can also pass in some of the node types. Thhis here will
# act like clicking on the cube object in the menus of Cinema.
self.MenuAddCommand(c4d.Ocube)
# Our little CommandData plugin.
self.MenuAddCommand(ID_CMD_ICON)
self.MenuSubEnd()
self.MenuFinished()
self.AddStaticText(2000, c4d.BFH_CENTER, name="Blah")
return True
def InitValues(self):
"""
"""
return True
def Command(self, id, msg):
"""
"""
return True
class IconCommandData(c4d.plugins.CommandData):
"""Just a plugin that acts as command to be executed.
"""
def Execute(self, doc):
"""Just prints something to the console.
"""
print("IconCommandData is being executed.")
return True
class MenuCommandData(c4d.plugins.CommandData):
"""The plugin that opens the menu.
"""
def __init__(self):
"""
"""
self._dialog = None
def Execute(self, doc):
"""Just opens IconMenueDialog.
"""
if self._dialog is None:
self._dialog = IconMenueDialog()
self._dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC,
pluginid=ID_CMD_MENU,
xpos=- 1,
ypos=- 1)
return True
def RestoreLayout(self, sec_ref):
"""Retores the dialog on layout changes.
"""
if self._dialog is None:
self._dialog = IconMenueDialog()
# Restores the layout
return self._dialog.Restore(pluginid=ID_CMD_MENU, secret=sec_ref)
def register():
"""Regissters the plugins.
"""
# A makeshift icon.
icon = c4d.bitmaps.BaseBitmap()
icon.Init(32, 32)
# Registration.
# The plugin with a icon.
c4d.plugins.RegisterCommandPlugin(id=ID_CMD_ICON,
str="IconCommand",
info=0,
icon=icon,
help="The command to call.",
dat=IconCommandData())
# The menu command that does not have an icon.
c4d.plugins.RegisterCommandPlugin(id=ID_CMD_MENU,
str="MenuCommand",
info=0,
icon=None,
help="Opens the dialog with a menu.",
dat=MenuCommandData())
if __name__ == "__main__":
register()