Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python Tag not updating (The Sequel)

    Cinema 4D SDK
    2
    7
    830
    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.
    • SwinnS
      Swinn
      last edited by

      Further to this post:
      https://developers.maxon.net/forum/topic/12559/python-tag-not-updating

      Where to I pass the str variable in the code? I do not see the place for it. Thanks.

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @Swinn could you post your code?

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • SwinnS
          Swinn
          last edited by m_adam

          import c4d
          import maxon
          
          def message(msg_type, data):
              if msg_type == c4d.MSG_NOTIFY_EVENT:
                  event_data = data['event_data']
                  msg_id = event_data['msg_id']
                  if msg_id == c4d.MSG_DESCRIPTION_POSTSETPARAMETER:
                      desc_id = event_data['msg_data']['descid']
                      if desc_id[1].id == 2398: # The ID of the User Data
                          txt = "Swinn"
                          pythonLogger = maxon.Loggers.Python()
                          pythonLogger.Write(maxon.TARGETAUDIENCE.ALL, txt, maxon.MAXON_SOURCE_LOCATION(1), maxon.WRITEMETA.UI_SYNC_DRAW)
                          mtx =  op.GetObject().GetMg()
                          mtx.off = mtx.off + c4d.Vector(10,0,0)
                          op.GetObject().SetMg(mtx)
          
          def main():
              obj = op.GetObject()
          
              # Check if we already listen for message
              if not obj.FindEventNotification(doc, op, c4d.NOTIFY_EVENT_MESSAGE):
                  obj.AddEventNotification(op, c4d.NOTIFY_EVENT_MESSAGE, 0, c4d.BaseContainer())
          
          if __name__=='__main__':
              main()
          
          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            Here in the latest S22 it's working as it should, and print Swinn to the console, on which version are you?

            Moreover what I was referring to is the LogerInterface.Write require a maxon.String, by convenience, if the passed data is a str (python Type) it will create on the fly a maxon.String, but if you pass another kind of data type, this will not be converted to a string even if there is a possible string representation, so you need to transform your datatype to a str the usual way is by doing str(YourData) so in our example, it will give us

            txt = c4d.Vector()
            pythonLogger = maxon.Loggers.Python()
            pythonLogger.Write(maxon.TARGETAUDIENCE.ALL, str(txt), maxon.MAXON_SOURCE_LOCATION(1), maxon.WRITEMETA.UI_SYNC_DRAW)
            

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • SwinnS
              Swinn
              last edited by

              I am on R20.

              1 Reply Last reply Reply Quote 0
              • M
                m_adam
                last edited by

                Sorry, I should have spotted it earlier, this issue is solved in R21.

                So, unfortunately, I don't have any workaround for you.
                Cheers,
                Maxime

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • SwinnS
                  Swinn
                  last edited by

                  Ah! Okay. Thanks. 🙂

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