GetUserDataContainer

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