Calling CommandData by name



  • Hi!

    I'm writing a C++ CommandData plugin that I call from Python with c4d.CallCommand(1000010)

    Is there any way to give it a name and call it by the name? I think GetScriptName() should do it but there's no info on how to use the name.



  • Hi,

    as far as I understand, you would like to be able to do a CallCommand(ID_MYCOMMANDPLUGIN) instead of a call with the numeric value, right?
    Unfortunately this is not possible, as the symbol parser does not scan the plugins. So you will need to define that ID within your Python code.

    Cheers,
    Andreas



  • I would like to call it by the actual plugin name name, like c4d.MyCommandData().
    I'll try to make some python shortcut functions that do that.

    Then what's CommandData::GetScriptName() useful for?



  • Hi,

    you can ignore GetScriptName(), it is used internally to construct strings (or rather IDs) to refer to the online help for example.

    While it is not possible to call a command by name, you can for example scan the list of plugins for the name you are looking for, resulting in the ID you need to call the command.
    Roughly like so:

    plugins = c4d.plugins.FilterPluginList(c4d.PLUGINTYPE_COMMAND, True)
    for plugin in plugins:
        if plugin.GetName() == "My Plugin Name":
                print plugin.GetFilename(), ": ", plugin.GetID()
    

    Cheers,
    Andreas



  • Hi,

    just want to ask, if can consider this topic as solved.

    Bye,
    Andreas