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

    GetUserDataContainer

    Scheduled Pinned Locked Moved PYTHON Development
    1 Posts 0 Posters 157 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 05/10/2014 at 03:07, xxxxxxxx wrote:

      I have a tag plugin that works correctly if I drag the tag to an object.
      However, when I save the scene with an object with the tag on it, the next time I open this previous save scene, the userdata is not correct.
      I get the below message in the console.
      The userdata is there, I can also see it, but it is not working properly.
      It is not "recognized" by the plugin.

      class UDTest(plugins.TagData) :

      def Init(self, node) :
              print "Init........................."
              print "Init Len(ud) : ", len(node.GetUserDataContainer())
              return True
              
          def Execute(self, tag, doc, op, bt, priority, flags) :
              print "Execute Len(ud) : ", len(tag.GetUserDataContainer())

      if (len(tag.GetUserDataContainer()) == 0) :     #Only init userdata when there is no userdata
                  bakeMessage = CreateUserDataStaticText(tag, "Message", "")
                  self.BAKEMESSAGE = bakeMessage[1].id 
                  clearBakeMessage = CreateUserDataBool(tag, "Clear", val=False)
                  self.CLEARBAKEMESSAGE = clearBakeMessage[1].id 
                  
                  return True    
                  
              #Clear bake message field
              if (tag[c4d.ID_USERDATA, self.CLEARBAKEMESSAGE]) :
                  tag[c4d.ID_USERDATA, self.CLEARBAKEMESSAGE] = False
                  tag[c4d.ID_USERDATA, self.BAKEMESSAGE] = ""
                  return True
                   
              return True
             
      if __name__ == "__main__":
          bmp = bitmaps.BaseBitmap()
          dir, file = os.path.split(__file__) 
          bitmapfile = os.path.join(dir, "res", "Icon.tif")
          #print bitmapfile
          result = bmp.InitWith(bitmapfile)
          if not result:
              print "Error loading bitmap!"
          
          okyn = plugins.RegisterTagPlugin(id=PLUGIN_ID, str="UDTest v01", info=c4d.TAG_VISIBLE|c4d.TAG_EXPRESSION, g=UDTest, description="",  icon=bmp)
          print "UDTest initialized, v01: ", okyn

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