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

    Python Tag Catch Button PressOn Parent Object

    PYTHON Development
    0
    5
    1.3k
    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 21/01/2015 at 06:40, xxxxxxxx wrote:

      Hi there, this code of Sebastian's :

      def message(id,data) :
          
          if id == c4d.MSG_DESCRIPTION_CHECKUPDATE:
          
              # check if button
              if data["descid"][1].dtype == c4d.DTYPE_BUTTON:
                  
                  # get id
                  buttonID = data["descid"][1].id

      works great to catch button presses of user data on the python tag itself.

      But I can't work out how to catch button presses on user data of the object to which the tag is attached.

      My purpose : I have a head controller with a load of sliders for face shapes. I have created 2 user data buttons on the controller : to either key all sliders or zero all sliders. I can deal with all the other code (in fact I have it already) but I can't work out how to catch the button presses.

      Thanks.

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

        On 22/01/2015 at 07:18, xxxxxxxx wrote:

        Hello,

        When a user-data button on an object is pressed, there is no special message send to the tags of that object.

        So you may have to add these buttons to your Python tag. Alternatively you could use a Python Generator as the controller objects and place your code there. Finally, you could also create a whole ObjectData plugin in Python.

        Best wishes,
        Sebastian

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

          On 23/01/2015 at 03:16, xxxxxxxx wrote:

          OK, thanks Sebastian. I will just move the rest of my control interface to the python tag to keep everything together.

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

            On 23/01/2015 at 05:32, xxxxxxxx wrote:

            Since R16, you can use BaseList2D.AddEventNotification()[URL-REMOVED].

            import c4d
              
            def message(msg_type, data) :
                if msg_type == c4d.MSG_NOTIFY_EVENT:
                    event_data = data['event_data']
                    if event_data['msg_id'] == c4d.MSG_DESCRIPTION_COMMAND:
                        desc_id = event_data['msg_data']['id']
                        if desc_id[1].id == 2:
                            print "Hello!"
              
            def main() :
                host = op.GetObject()
                if not host.FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE) :
                    bc = c4d.BaseContainer()
                    host.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, bc)
            

            Here's an example scene: AddEventNotification_Example.c4d


            [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

              On 23/01/2015 at 06:49, xxxxxxxx wrote:

              Thanks for the solution Niklas.
              I've saved your scene file for future reference & off to read the python SDK entry to understand it a bit better.

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