Parameters for commandData Plugin

  • Hi!

    Is it possible to add a commandData plugin multiple times to a menu, but label it differently and pass a parameter to Execute()? Or is the only way to do that via GetSubContainer()?

    I'm thinking of something like

    menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_12345, menuLabel1, menuParam1)
    menu.InsData(c4d.MENURESOURCE_COMMAND, "PLUGIN_CMD_12345, menuLabel2, menuParam2)

    to then do something like this in Execute

    def Execute(self, doc, param):
        if param == x:
        elif param == y:


  • Hello,

    you cannot add a new argument to the Execute() function.

    Instead, you could write a more generic CommandData plugin that stores an internal value. You could register different versions of that command using different plugin IDs and then call these different versions. Something like this:

    class DynamicCommand(plugins.CommandData):
        # internal value
        _setting = 0
        def __init__(self, setting):
            # set internal value on creation
            self._setting = setting
        def Execute(self, doc):
            # use internal value on execution
            return True

    Which can be registered using constructors with different arguments:

    plugins.RegisterCommandPlugin(id_a, "Command A", c4d.PLUGINFLAG_HIDEPLUGINMENU, bitmaps.BaseBitmap(), "", DynamicCommand(123))
    plugins.RegisterCommandPlugin(id_b, "Command B", c4d.PLUGINFLAG_HIDEPLUGINMENU, bitmaps.BaseBitmap(), "", DynamicCommand(456))

    Best wishes,

  • Hi Sebastian!

    Thanks for your answer. I was looking for something a little more flexible than registering multiple plugins, but I guess GetSubContainer will have to do :)