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) :
if id == c4d.MSG_DESCRIPTION_CHECKUPDATE:
# check if button
if data["descid"][1].dtype == c4d.DTYPE_BUTTON:
# get id
buttonID = data["descid"][1].idworks 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.
-
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 -
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()
[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.
-
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.