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

    Listening for Checkbox Clicks in User Data

    PYTHON Development
    0
    3
    1.9k
    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 22/08/2018 at 14:13, xxxxxxxx wrote:

      Hello,
      Is it possible, with a Python tag or otherwise, to listen for the click of an object's User Data checkbox? I have gotten this to work with the User Data button in the past. I'm looking to run some scripts when the user checks a "Use IK" checkbox.

      I tried overriding the "message" method in my Python tag, but I couldn't find any of the attributes for the data object that gets passed as a parameter. In my web searches, it seemed that attributes such as 'descid' only existed for certain types of message data.

      Any clarification on how to set this up (and decipher the message data) would be very helpful. Thank you.

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

        On 23/08/2018 at 02:03, xxxxxxxx wrote:

        Hi BlastFrame !

        Actually there is a way, but is not recommended and pretty experimental, so if strange behavior occurs, we can't do anything. In the same time it's the only solution.
        Whith that said we get AddEventNotification, which allow to receive message from another object.
        Here is the code of the python tag

        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_POSTSETPARAMETER:
                    desc_id = event_data['msg_data']['descid']
                    if desc_id[1].id == 1:
                        print op.GetObject()[c4d.ID_USERDATA,1]
          
        def main() :
            obj = op.GetObject()
            
            # Check if we already listen for message
            if not obj.FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE) :
                obj.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, c4d.BaseContainer())
        

        If you have any questions, pelase let me know.
        Cheers,
        Maxime.

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

          On 24/08/2018 at 15:02, xxxxxxxx wrote:

          This works! Thank you, Maxime.

          It may be worth calling out that this line's id  attribute is the ID assigned when creating the User Data:
          if desc_id[1].id == 1:

          It took me a little to figure this out.

          Thank you, again!

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