Python Tag Catch Button PressOn Parent Object

On 21/01/2015 at 06:40, xxxxxxxx wrote:

Hi there, this code of Sebastian's :

def message(id,data) :
        # 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.


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


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,

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.

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

Since R16, you can use BaseList2D.AddEventNotification().

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

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.