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

    Howto trigger CommandData::GetState()

    Cinema 4D SDK
    r20 c++
    2
    5
    782
    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.
    • C4DSC
      C4DS
      last edited by C4DS

      Hi,
      I have a GeUserArea where items are drawn. User can select one or more of these items.
      Next to this I have several actions, defined as CommandData derived plugins, which can each perform a specific action on the selected item(s). I am able to control the state of these CommandData icons, using GetState() to obtain information from my userarea and return the appropriate value to show the icon/menu-item enabled or disabled, checked or unchecked.

      Which message is actually responsible for triggering the CommandData::GetState()?
      As I need to trigger the GetState when an item is (de)selected in the userarea, so that the CommandData can check the userarea and decide to enable/disable the command.

      Thanks

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hello,

        I'm not sure if you are creating a customDataType + customGUI or only a customGUI. I'm also not sure where you are storing your data. I'm afraid you are storing your data in your GeUserArea witch is not a good place to.

        Your data should be stored in a BaseContainer. This BaseContainer can be stored in a tag, an object, the Document itself.

        I can still try to point to the right direction :

        You don't have to send a message to trigger directly the CommandData::GetState()

        There's an example that could help you in the sdk //sdk/source/gui/customdata_customgui.cpp or you can see the file on github

        You will see that the GeUserArea use SendParentMessage to tell the parent that something have changed.

        BaseContainer m(BFM_ACTION);
        m.SetInt32(BFM_ACTION_ID, GetId());
        SendParentMessage(m);
        

        The parent will catch this message and will send a message to its parent. (in the exemple, Bool
        ExampleCustomGUIDots::Command(Int32 id, const BaseContainer &msg))

        So at the end, Cinema4D will trigger what it need and GetState()

        Let me know if it's not clear.

        Cheers
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        C4DSC 1 Reply Last reply Reply Quote 0
        • C4DSC
          C4DS @Manuel
          last edited by

          @m_magalhaes
          Sorry, I didn't explain well enough.

          I have a CommandData derived plugin with a GeDialog. The only gadget of the dialog is a GeUserArea.
          In the userarea I draw items, which the user can "select" by simply left-mouse-clicking in the bounding box of the item.

          Next I have several other CommandData derived plugins.
          These are used to activate actions on the selected items.
          What I try to perform is to enable/disable these "action" depending on the selected item in the userarea.

          If I implement the SendParentMessage in the userarea (on successful item selection), it triggers the GeDialog::Command, which then triggers its parent with another SendParentMessage. But the parent of the GeDialog is its CommandData, while I need to trigger the "action" CommandDatas instead, in order to update their state.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            hello,

            In this context you can use EventAdd()

            Cheers
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 1
            • C4DSC
              C4DS
              last edited by C4DS

              I had noticed that the EVMSG_CHANGE was actually triggering the GetState of my CommandDatas, but I was wondering if a different approach was available.
              Still, I am OK with the EventAdd() solution. Thanks.

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