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

    GeDialog Save Layout

    SDK Help
    0
    5
    462
    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 28/04/2016 at 15:30, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R16 
      Platform:    Mac  ;  
      Language(s) :     C++  ;

      ---------
      Hello, I have a GeDialog plugin and I'm trying to make it so when it's saved to a Layout with Save as Startup Layer for example, that certain parameters are saved are saved to the Layout.  The parameters control the appearance of the dialog so if they aren't saved and loaded as well then it looks different.

      I noticed BFM_LAYOUT_SETDATA  and BFM_LAYOUT_GETDATA but I couldn't get anything from either of them.  Thank you for any help.

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

        On 28/04/2016 at 16:24, xxxxxxxx wrote:

        One possible solution is to save the appearance information to the World Plugin Data Container (using a unique plugin ID for reference) and load similarly.  See GetWorldPluginData() and SetWorldPluginData().  These set and get plugin-specific information stored globally to the Cinema 4D Preferences.

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

          On 28/04/2016 at 19:43, xxxxxxxx wrote:

          Another solution would be to store the information in a SceneHook so that the dialog information is per scene.

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

            On 29/04/2016 at 00:38, xxxxxxxx wrote:

            Hi,

            As you've already find out, to store per-layout data for your dialog use BFM_LAYOUT_SETDATA and BFM_LAYOUT_GETDATA messages. Let see how they have to be used.

            For instance in the ActiveObjectDialog example of cinema4dsdk we could save the "Lock Element"checkbox status (stored in the dialog class as  lock member):

            Bool ActiveObjectDialog::Message(const BaseContainer& msg, BaseContainer& result)
            {
              switch (msg.GetId())
              {
                case BFM_LAYOUT_SETDATA:  // Called when a new layout is set
                {
                  // Retrieve layout data to set with the message ID
                  const BaseContainer *bc = msg.GetContainerInstance(BFM_LAYOUT_SETDATA);
                  if (bc)
                  {
                    // Obtain dialog layout container with the unique ID of the plugin
                    const BaseContainer* data = bc->GetContainerInstance(ID_ACTIVEOBJECT);
                    if (data)
                    {
                      lock = data->GetBool(0);
                    }
                  }
                  return true;
                }
                case BFM_LAYOUT_GETDATA:  // Called when a layout is saved
                {
                  // Setup dialog layout container
                  BaseContainer data;
                  data.SetBool(0, lock);
              
                  // result container has to be initialized with ID 0
                  result = BaseContainer(0);
                  // Set dialog layout container with the unique ID of the plugin
                  result.SetData(ID_ACTIVEOBJECT, data);
                  return true;
                }
              }
              
              return GeDialog::Message(msg, result);
            }
              
            Bool ActiveObjectDialog::InitValues(void)
            {
              if (!GeDialog::InitValues())
                return false;
              
              // Lock Element checkbox has to be initialized here
              // Otherwise saved layout data isn't reflected  
              SetBool(IDC_AO_LOCK_ELEMENT, lock);
              
              ...
              
              return true;
            }
            
            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              On 03/05/2016 at 10:15, xxxxxxxx wrote:

              Thanks you for the responses.

              I have your method working Yannick, thank you.

              Robert, I had seen you mention those functions in a different post before.  My understanding of them is that they're completely global, so they work for having new set parameters for the plugin across the board.  If I only wanted this parameter to be different when loaded from a layout that it was saved with I'd want to go with Yannick's method correct?

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