Hello guys,
I'm trying to make a python tag plugin with button. My goal is to add description to tag description when user hit add button in tag property.
I feel my code works properly but Atrribute Manager doesn't update until I move the current time indicator (see below).
Is it possible to add descripton dynamically with button in python plugin?
I searched through this forum and I think "Update button" might be related but I can't understand enough... so please help me if you know the workaround!
Here's my code.
test_tag.pyp
import os
import c4d
from c4d import plugins
PLUGIN_ID = *******
START_NO = 1100
class TestTagData(c4d.plugins.TagData):
def Init(self, node):
self.links_list = []
pd = c4d.PriorityData()
if pd is None:
raise MemoryError("Failed to create a priority data.")
pd.SetPriorityValue(lValueID = c4d.PRIORITYVALUE_MODE, data = c4d.CYCLE_EXPRESSION)
node[c4d.EXPRESSION_PRIORITY] = pd
return True
def Execute(self, tag, doc, op, bt, priority, flags):
return c4d.EXECUTIONRESULT_OK
def Message(self, node, type, data):
if type == c4d.MSG_DESCRIPTION_COMMAND:
if data["id"][0].id == c4d.TTESTTAG_ADD_BUTTON:
bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_BASELISTLINK)
self.links_list.append(bc)
return True
def GetDDescription(self, node, description, flags):
if not description.LoadDescription(node.GetType()):
return False
singleId = description.GetSingleDescID()
groupId = c4d.DescID(c4d.DescLevel(c4d.TTESTTAG_LINKS_GROUP, c4d.DTYPE_GROUP, node.GetType()))
links_num = len(self.links_list)
if links_num > 0:
for i in range(links_num):
paramId = c4d.DescID(c4d.DescLevel(START_NO + (i + 1)))
if singleId is None or paramId.IsPartOf(singleId)[0]:
bc = self.links_list[i]
bc.SetString(c4d.DESC_NAME, "Controller " + str(i + 1))
bc.SetString(c4d.DESC_SHORT_NAME, "Controller " + str(i + 1))
bc.SetInt32(c4d.DESC_ANIMATE, c4d.DESC_ANIMATE_ON)
if not description.SetParameter(paramId, bc, groupId):
return False
return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
if __name__ == "__main__":
c4d.plugins.RegisterTagPlugin(id = PLUGIN_ID, str = "Test Tag", info = c4d.TAG_EXPRESSION|c4d.TAG_VISIBLE, g = TestTagData, description = "ttesttag", icon = None)
ttesttag.res
CONTAINER Ttesttag
{
NAME Ttesttag;
INCLUDE Texpression;
GROUP ID_TAGPROPERTIES
{
GROUP TTESTTAG_LINKS_GROUP
{
GROUP
{
COLUMNS 2;
BUTTON TTESTTAG_ADD_BUTTON { SCALE_H; }
BUTTON TTESTTAG_REMOVE_BUTTON { SCALE_H; }
}
}
}
}
---------- User Information ----------
Cinema 4D version: R23
OS: Windows 10
Language: Python