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

    [SOLVED] Dynamic Dropdown List

    SDK Help
    0
    4
    1.2k
    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.
    • H
      Helper
      last edited by

      On 09/07/2018 at 21:02, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R18 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi all,

      I want to have a drop down list that I can change on the fly with user data. The list is a list of image extensions and I would like to allow users to put in there own custom extensions and then add this to this list.

      The user clicks on custom, enters a custom extension and this is saved to a user configuration file (I have everything up to this point working fine). Where I'm stuck is how I can populate this list with the saved data so that the user can see their custom extensions each time they open a file.

      You can see the code if that makes anything clearer on my GitHub page for the project, the files of interest here are SMDLoader.cpp/.h and fsmdloader.res

      https://github.com/xNWP/Cinema-4D-Source-Tools

      Thank you in advanced to anyone who can help point me in the right direction !!

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 09/07/2018 at 22:33, xxxxxxxx wrote:

        Here's what I did to fill a dropdown box with filenames and a custom entry

        Bool DisplayMode::GetDDescription(GeListNode* node, Description* description, DESCFLAGS_DESC& flags)  
        {  
          if (!description->LoadDescription(DISPLAYMODE_DESC_PLUGIN_ID))  
              return false;  
          
            // === CHECKER ===   
          
          // fill the dropdown with all available checker types  
          const DescID *singleid = description->GetSingleDescID();  
          DescID cid = DescLevel(CHECKER_TYPE, DTYPE_LONG, 0);  
          if (!singleid || cid.IsPartOf(*singleid, nullptr)) // important to check for speedup c4d!  
          {  
              SortedStringArray checkerFilenames;  
              // read the available checker bitmap filenames
                {  
                  ...   
              }  
          
              // add a fixed "Custom Checker" entry in the list,  
              // separated from the file entries  
              // (leave out separator when no file entries)  
              BaseContainer listBC;  
              listBC.SetString(CUSTOM_CHECKER_ID, "Custom Checker");  
              if (checkerFilenames.GetCount() > 0)  
                  listBC.SetString(-1, ""); // separator  
          
              for (SortedStringArray::ConstIterator it = checkerFilenames.Begin(); it != checkerFilenames.End(); ++it)  
                  listBC.SetString(Int32(it - checkerFilenames.Begin()), *it);  
                
              // add the items to the dropdown gadget  
              BaseContainer comboBC = GetCustomDataTypeDefault(DTYPE_LONG);  
                // re-use the original label from the description  
              {  
                  BaseContainer* bc = description->GetParameterI(cid, nullptr);  
                  comboBC.SetString(DESC_SHORT_NAME, bc->GetString(DESC_SHORT_NAME));  
              }  
              comboBC.SetInt32(DESC_ANIMATE, DESC_ANIMATE_OFF);  
              comboBC.SetContainer(DESC_CYCLE, listBC);  
          
                // store the data into the description  
              if (!description->SetParameter(cid, comboBC, DescLevel(0)))  
                  return FALSE;  
          
        
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 10/07/2018 at 01:32, xxxxxxxx wrote:

          Hello,

          as C4DS showed, you can edit the parameter description of a NodeData based element by implementing GetDDescription(). There are multiple manuals and example available:

          • NodeData::GetDDescription() Manual
          • Description Manual
          • Description Settings Manual

          An example of editing a drop down list is found in sculptdeformer.cpp.

          best wishes,
          Sebastian

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            On 10/07/2018 at 15:52, xxxxxxxx wrote:

            Thank-You both!

            This has absolutely done the trick and is working flawlessly 🙂

            1 Reply Last reply Reply Quote 0
            • First post
              Last post