Button is pressed on startup of tag plugin[SOLVED]

On 08/10/2014 at 09:21, xxxxxxxx wrote:

Hi, I created a little plugin with a few parameters and a button.
I want to do stuff as a reaction on button clicks, but when I start the plugin, the button gets executed allready once. How can I avoid this?

This is my code for the button:

def Execute(self, tag, doc, op, bt, priority, flags) :

data = tag.GetDataInstance()

if MYBUTTON:
          print "The button is pressed"

return True

On 08/10/2014 at 10:57, xxxxxxxx wrote:

add this function:

def GetMessageID(data) : #This custom method is used to get the id of your gizmos
    if data is None:
        return
    try:
        return data["id"][0].id
    except:
        return

and add this to the Message:

def Message(self, op, type, data) :
    id = GetMessageID(data) # calls to the custom GetMessage() method

if id == MYBUTTON:
      print "The button is pressed"

Thanks to Scott on this forum for teaching me it.

On 09/10/2014 at 02:39, xxxxxxxx wrote:

Thanks for the answer!!

I didn't need to add the GetMessageID though. Fixed it with:

def Message(self, node, type, data) :
      if type == c4d.MSG_DESCRIPTION_COMMAND:
          if data['id'][0].id == MOMBUTTON:
              print "The button is pressed"

return True

On 09/10/2014 at 02:47, xxxxxxxx wrote:

casimir your solution is much cleaner. That's exactly how you should do it

On 09/10/2014 at 13:08, xxxxxxxx wrote:

Thanks NiklasR!! Your words give me a boost to continue delving into it, harder than ever 😄