UNSOLVED Get list of all commands and their associated information

Hello Guys,

  1. Is it possible to get a full list of command ID ?

For now I understand from different forum posts that the only way is to get it from the command palette (for instance in https://plugincafe.maxon.net/topic/3168/2548_command-id/2)
For now I am doing this kind of recursion to get a list of command from the ui.
The code below shows me two kind of results:

  1. IDM_XXX
  2. PLUGIN_CMD_${ID}

The first one is a string while the second contains an id but does not corresponds to the targeted command id.

void EnumerateCmds(BaseContainer* item) {
	BrowseContainer bc(item);
	Int32 id = 0;
	GeData* dat = nullptr;
	while (bc.GetNext(&id, &dat))
	{
		switch (id) {
			case MENURESOURCE_SUBMENU:
				DiagnosticOutput("SUBMENU [");
				EnumerateCmds(dat->GetContainer());
				DiagnosticOutput("]");
				break;
			case MENURESOURCE_STRING:
				DiagnosticOutput("MENURESOURCE_STRING " + dat->GetString() + "[");
				EnumerateCmds(dat->GetContainer());
				DiagnosticOutput("]");
				break;
			case MENURESOURCE_COMMAND:
				DiagnosticOutput("MENURESOURCE_COMMAND=" + dat->GetString())
				break;
			case MENURESOURCE_SEPERATOR:
				break;
			case MENURESOURCE_SUBTITLE:
				DiagnosticOutput("subtitle="+ dat->GetString());
				break;
			case MENURESOURCE_MENURESOURCE:
				DiagnosticOutput("MENURESOURCE_MENURESOURCE=" + dat->GetString() + "[");
				EnumerateCmds(dat->GetContainer());
				DiagnosticOutput("]");
				break;
			case MENURESOURCE_SUBTITLE_ICONID:
				DiagnosticOutput("MENURESOURCE_SUBTITLE_ICONID id value: " + dat->GetInt32());
				break;
			case MENURESOURCE_ASSET:
				DiagnosticOutput("MENURESOURCE_ASSET" + dat->GetString() + "[");
				break;
			default:
				DiagnosticOutput("error");
				break;
		}
  1. Are command's id same for their icon ? Otherwise how could we fetch it?

Thank you in advance for any help

Best

Hi @user168462, first of all welcome to plugincafe!

To obtain the full list of Command which are implemented by a CommandData, you can call FilterPluginList.
This function will return you a list of plugin in an AtomArray. Each entry within this AtomArray can safetly be casted to a BasePlugin.

Correct if there is an icon supplied for a Command, the Command ID is the same than the Icon ID. If you want to retrieve the icon of an Command ID, you can use the GetIcon function to retrive it.

Cheers,
Maxime.

Thank you m_adam it works perfectly !
Here is the code if it helps someone

	AutoAlloc<AtomArray> pList;
	FilterPluginList(pList, PLUGINTYPE::COMMAND, true);
	for (size_t i = 0; i < pList->GetCount(); i++)
	{
		auto elem = static_cast<BasePlugin*> (pList->GetIndex(i));
		DiagnosticOutput(elem->GetName()+ ", "+ String::IntToString(elem->GetID())+ ", " + GetCommandHelp(elem->GetID()));
	}

I have also another question, before I was trying to discover commands thought the menu then I could categorize it.
Do you think there is a way to collect such information (for instance know that "New project" command is located into file submenu.

Thanks

Hi @user168462, sorry for the late reply, I was away last week to the MAXON company meeting.

Regarding your request sadly there is no builtin way for doing something like that, you will need to iterate each menus and submenu.
For hard-coded menu you can find them in resource\modules\c4dplugin\menus, but this will not cover all menus and if you want to address one in particular, it's better to ask here so we can look into the code.

Cheers,
Maxime.