Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Button is pressed on startup of tag plugin[SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 380 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

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

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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 😄

              1 Reply Last reply Reply Quote 0
              • First post
                Last post