On 02/11/2015 at 03:44, xxxxxxxx wrote:
However, if you want that button, here's what a message responder does.
You need to have a method "message", which receives all the messages sent to objects. There, you check for the right type of message, the button type, and finally the id of this button. If all of this identifies the proper message that you want to respond to, you insert your responder code.
(In more complicated examples that need to react to many different messages, the responder code would probably be a separate method again, but since you only listen for a single message, you can insert it right there...)
def message(id,data) :
if id == c4d.MSG_DESCRIPTION_CHECKUPDATE:
# check if button
if data["descid"].dtype == c4d.DTYPE_BUTTON:
# get id
buttonID = data["descid"].id
if buttonID == 1 :
# execute your code here
def main() :
pass # not needed because no execution is necessary
Now the main() function is empty (this is the "Execute" method of a tag in this case), and the responder returns early, which means it will only use as much calculation time as needed.
For the code above, the button needs to be in the UserData of the tag! Otherwise, the tag may not receive the message properly. In the link above from the other post, you will find a concept to receive the parent object's messages too; I'm not going to repeat it here.
Though, Sebastian is right, doing this as a command script seems more logical, since you could assign this to an icon and put that icon anywhere in the GUI, making it scene-independent.