Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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 Checkbox state [SOLVED]

    SDK Help
    0
    4
    432
    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 30/01/2017 at 01:00, xxxxxxxx wrote:

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

      ---------
      Hello everyone,

      I'm new to C4D C++ plugin dev, and I have a small checkbox problem. Inside the cinema4dsdk project, in gedialog_gadgets.cpp there is this code :

      {...}        case(DIALOGELEMENTS::RADIO_TEXT) :  
            {  
                Bool checked;  
        
                if (GetBool(ID_DYMAMIC_GADGET, checked))  
                {  
                    if (checked)  
                        SetString(ID_CONSOLE, "checked");  
                    else  
                        SetString(ID_CONSOLE, "not checked");  
                }  
                break;  
            }{...}
      

      It's called whenever you click a "Read Data" button. In my own plugin, i have a similar setup, but the code gets called from the Command() function override of my GeDialog :

          virtual Bool Command(Int32 id, const BaseContainer &msg)  
        {  
            switch (id)  
            {  
                case (DLG_CHK_ACTIVE) :  
                {  
                    Bool checked;  
                    if (GetBool(DLG_CHK_ACTIVE, checked))  
                    {  
                        if (checked)  
                        {  
                            WriteLineToConsole("Active.");  
                        }  
                        else  
                        {  
                            WriteLineToConsole("Inactive.");  
                        }  
                    }  
                }  
                break;  
            }  
            return TRUE;  
        }
      

      My problem is that whether i check or uncheck the checkbox, I get an "Inactive." line on my console. My WriteLineToConsole() function works as expected and its purpose is just to add a little prompt (later a timestamp and useful info) to the line.

      Here is what i get after clicking 6 times on my checkbox :
      After 6 clicks
      I would expect something like :
      "-> Active.
      -> Inactive.
      -> Active.
      -> Inactive.
      -> Active.
      -> Inactive."

      Is there anything I am doing wrong?

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

        On 30/01/2017 at 01:58, xxxxxxxx wrote:

        Hmmmm....

        I tweaked my code a bit, to print ids in my console, get info from the msg argument and thing like that. In the end i ended up with the same code i posted previously and the checkbox works as expected...

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

          On 30/01/2017 at 05:00, xxxxxxxx wrote:

          Hi aTom, thanks for writing us and welcome to the PluginCafè.

          With reference to your question, please note that the way you're trying to recover the checkbox value is improper and lead to this wrong behavior. You have instead to rely on the BaseContainer instance provided as "msg" parameter in the Command() method to retrieve the value of the checkbox or of any other item which has originally fired the Command() call.
          By accessing the value provided by the BaseContainer instance via GetData() you're accessing the referring GeData instance actually responsible to provide you with the GUI element value.

          ...
          ...
              switch (id)  
            {  
            case CHECKBOX_ID:  
                GeData actionValue = msg.GetData(BFM_ACTION_VALUE);  
                if (actionValue.GetBool())  
                    GePrint("checkbox is checked");  
                else  
                    GePrint("checkbox is unchecked");  
                break;  
            }
          ...
          ...
          

          Best, Riccardo

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

            On 30/01/2017 at 08:10, xxxxxxxx wrote:

            Hi Knickknac,

            Thank you for your answer, i understand the BaseContainer object a lot better now.

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