Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Get list of all commands and their associated information

    Cinema 4D SDK
    c++ maxon api sdk
    3
    6
    1.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • U
      user168462
      last edited by user168462

      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://developers.maxon.net/forum/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

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        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.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • U
          user168462
          last edited by user168462

          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

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            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.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • ferdinandF
              ferdinand
              last edited by

              Hello @m_adam,

              without any further questions or other postings, we will consider this topic as solved and flag it as such by Friday, 17/06/2022.

              Thank you for your understanding,
              Ferdinand

              MAXON SDK Specialist
              developers.maxon.net

              1 Reply Last reply Reply Quote 0
              • U
                user168462
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post