On 09/02/2013 at 17:59, xxxxxxxx wrote:
Hi all,
Ive got a Plugin-tag and Id like to add or remove userdatas. Adding works, but removing is a problem. I have already tried out various things, but nothing has worked. Here are some naked lines. Which command do I need to update the userdatacontainer immediately?
import os
import math
import sys
import c4d
from c4d import plugins, utils, bitmaps, gui
# be sure to use a unique ID obtained from www.plugincafe.com
PLUGIN_ID = 145268788 #TestID
class TagPlugin(plugins.TagData) :
def Init(self, node) :
return True
def Message(self, node, type, data) :
if type==c4d.MSG_DESCRIPTION_COMMAND:
if data["id"][0].id == 10001: self.AddUD(node)
elif data["id"][0].id == 10002: self.RemoveUD(node)
return True
def Execute(self, tag, doc, op, bt, priority, flags) :#
return c4d.EXECUTIONRESULT_OK
def AddUD(self, node) :
data = c4d.GetCustomDatatypeDefault(c4d.DTYPE_BOOL)
data[c4d.DESC_NAME] = "Enable"
node[node.AddUserData(data)] = False
def RemoveUD(self,node) :
node.RemoveUserData(1)
if __name__ == "__main__":
dir, file = os.path.split(__file__)
bmp = bitmaps.BaseBitmap()
bmp.InitWith(os.path.join(dir, "res", "icon.tif"))
plugins.RegisterTagPlugin(id=PLUGIN_ID,
str="TagPlugin",
g=TagPlugin,
description="TagPlugin",
icon=bmp,
info=c4d.TAG_MULTIPLE|c4d.TAG_EXPRESSION|c4d.TAG_VISIBLE)
Another problem Ive got are separators. For example:
def AddUD(self, node) :
data = c4d.GetCustomDatatypeDefault(c4d.DTYPE_BOOL)
data[c4d.DESC_NAME] = "Enable"
node[node.AddUserData(data)] = False
data = c4d.GetCustomDatatypeDefault(c4d.DTYPE_SEPARATOR)
data[c4d.DESC_SEPARATORLINE] = True
node.AddUserData(data)
data = c4d.GetCustomDatatypeDefault(c4d.DTYPE_BOOL)
data[c4d.DESC_NAME] = "Enable2"
node[node.AddUserData(data)] = False
The separators are listed in the UserDataManager but hidden in the interface. I wasn´t able to get a solution. What is wrong?
Thanks in anticipation
rown
**