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

    How to detect click on a item in InExclude list?

    Cinema 4D SDK
    python
    2
    10
    1.6k
    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.
    • R
      rui_mac
      last edited by

      How can I detect what was the item that was clicked on a InExclude list?
      I mean, I have an InExclude list defined in a res file.
      And I would like to be able to detect when a new item in the list was clicked. I believe it should be done inside the Message method, but I can't find out how to.
      I did found that the IN_EXCLUDE_FLAG_SEND_SELCHANGE_MSG key should be set to True, but I don't know how to set it.
      Anyone can help?

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

        Hi @rui_mac when registered in a GeDialog you need to set IN_EXCLUDE_FLAG_SEND_SELCHANGE_MSG to true within the BaseContainer settings of your CustomGui. Within a description you can specify SEND_SELCHNGMSG.

        Once you have this the InExclude list custom gui will send the message MSG_DESCRIPTION_INEX_SELCHANGED to its parent and then you can iterate each entry of the InExclude and retrieve its selection state with GetData()->GetBool(IN_EXCLUDE_DATA_SELECTION).

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • R
          rui_mac
          last edited by

          Thank, you Maxime.
          I'm not using e GeDialog. I'm creating the interface with a res file, like I stated in the text above.
          The description of the res file, for the InExclude is as follows:

          IN_EXCLUDE VMM_ATOMS
          {

          NUM_FLAGS 1;
          INIT_STATE 0;
          
          IMAGE_01_ON 1037349;
          IMAGE_01_OFF 1037349;
          
          SEND_SELCHNGMSG 1;
          
          ACCEPT {5682;}
          }
          

          However, it seems not to be working. What could I be doing wrong?

          1 Reply Last reply Reply Quote 0
          • R
            rui_mac
            last edited by

            When I try to get the data from the InExclude with something like

            the_data = my_inex.GetData()
            

            I get an error saying...

            AttributeError: 'c4d.InExcludeData' object has no attribute 'GetData'

            1 Reply Last reply Reply Quote 0
            • R
              rui_mac
              last edited by

              I can GetData from each element of the InExclude list, as it returns a c4d.BaseList2D object.
              But, even so, I can't find out if it is selected or not.
              I tried checking the bits of the c4d.BaseList2D and I always get 0 (zero).

              1 Reply Last reply Reply Quote 0
              • R
                rui_mac
                last edited by

                From what I gathered, the c4d.BaseList2D that is returned by

                op = inexclude_list.ObjectFromIndex(doc,i)
                

                is the object itself (a polygonal object, or a tag, or a material, depending on what types of objects the InExclude list accepts).
                So, I need a way to access the data of the list, to be able to determine which item is selected (was clicked on).
                And that is really complicated, it seems.

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

                  Hi @rui_mac sorry I overlooked the fact that you are on Python and assumed you are on C++.
                  So indeed this is not possible in Python as InExcludeData::GetData is not available in Python. I've added it and it now work as expected. This will be part of the next release (not the one from today)
                  inexcludedata.jpg

                  With that said in Python with the next res I was able to receive correctly MSG_DESCRIPTION_INEX_SELCHANGED so you should be able to do it as well.

                  GROUP ID_OBJECTPROPERTIES
                  {
                      IN_EXCLUDE ID_INEXCLUDE 
                      { NUM_FLAGS 1;
                      INIT_STATE 0;
                  
                      IMAGE_01_ON 1037349;
                      IMAGE_01_OFF 1037349; 
                  
                      SEND_SELCHNGMSG 1;
                  }
                  

                  And in my message method within the ObjectData

                  if msgId == c4d.MSG_DESCRIPTION_INEX_SELCHANGED:
                      inExcludeData = node[ID_INEXCLUDE]
                      for i in range(inExcludeData.GetObjectCount()):
                          isSelected = inExcludeData.GetData(i)[c4d.IN_EXCLUDE_DATA_SELECTION]
                          name = inExcludeData.ObjectFromIndex(node.GetDocument(), i).GetName()
                          print(name, isSelected)
                  

                  Is correctly trigered and print the selected version, of course you dont have GetData.

                  Cheers,
                  Maxime.

                  MAXON SDK Specialist

                  Development Blog, MAXON Registered Developer

                  R 1 Reply Last reply Reply Quote 1
                  • R
                    rui_mac @m_adam
                    last edited by

                    @m_adam

                    Thank you very much. It is a nuisance not to be able to get the selection now.
                    But it is better late than ever 🙂

                    So, for new, it is completely impossible, as in... there is no workaround?
                    Is there any other way to have a gizmo that allows the user to drag tags, show them on a list, be able to drag them up and down, and detect if there is a click on one of them?

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

                      Correct for the moment there is no workaround in Python, the only workaround would be to do it in C++.

                      Except doing your own custom gui which is again not possible in Python, not really the only way would be to do a button that will open a GeDialog and within this GeDialog do a TreeView.
                      Cheers,
                      Maxime.

                      MAXON SDK Specialist

                      Development Blog, MAXON Registered Developer

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

                        Hi with the 2023.1 release, the method InExcludeData.GetData have been added to the Python SDK.

                        Cheers,
                        Maxime.

                        MAXON SDK Specialist

                        Development Blog, MAXON Registered Developer

                        1 Reply Last reply Reply Quote 0
                        • M m_adam referenced this topic on
                        • First post
                          Last post