Detect a User Data button
On 20/05/2016 at 09:09, xxxxxxxx wrote:
Cinema 4D R17 has a User Data type of Button.
How can a script detect that a User Data button was clicked?
On 20/05/2016 at 11:15, xxxxxxxx wrote:
This was posted in forum somewhere.
But I'll save you the trouble of looking for it.
#This is how to capture the button click event on the new button UserData gizmo in R16 #The code goes in a python tag #Assumes that the UD button is at index #1 and the UD button is on the object...not the 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_COMMAND: desc_id = event_data['msg_data']['id'] if desc_id.id == 1: print "UD Button Pressed" def main() : obj = op.GetObject() bc = c4d.BaseContainer() obj.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, bc)
On 20/05/2016 at 11:24, xxxxxxxx wrote:
Great!!! Thank you, Scott
On 23/05/2016 at 01:39, xxxxxxxx wrote:
Event notifications aren't recommended but that's the current solution.
However, note that the upcoming Service Update for R17 fixes this issue catching user data buttons pressed in Python tags.
The MSG_DESCRIPTION_COMMAND will be sent without the need for registering an event notification.
On 23/05/2016 at 03:07, xxxxxxxx wrote:
Great to know that.
I'm considering the idea of writing a book on python (just like I did, on COFFEE) and all this information is very valuable.
On 05/07/2016 at 02:50, xxxxxxxx wrote:
Thank you, Scott, for a nice code snippet, but i have no idea how to use it in XPresso. Can you show a little example?
On 05/07/2016 at 08:34, xxxxxxxx wrote:
I don't know that either Mike.
Maybe the support guys have an answer?
On 06/07/2016 at 02:05, xxxxxxxx wrote:
The Python XPresso node doesn't support the message() function.
And it's not a good idea to catch a button pressed inside a Python node. An XPresso node should only calculate output(s) with its input(s).
What operation(s) would be performed when the button is pressed?