Solved Attribute Manamger Update Delay When Description Added Dynamically

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.

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)
        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)


    NAME Ttesttag;
    INCLUDE Texpression;

                COLUMNS 2;

---------- User Information ----------

Cinema 4D version: R23
OS: Windows 10
Language: Python

@beatgram said in Attribute Manamger Update Delay When Description Added Dynamically:

self.links_list = []

This is an instance attribute that you change during the button handling. Changing it will not automatically cause C4D to redraw the GUI, which would be necessary to execute GetDDescription where the interface is actually built. Try to enforce the redraw with c4d.EventAdd().

@Cairyn Thank you for taking your time.

I see. So to execute GetDDescription, "c4d.EventAdd()" should be added to Message() function like below?

    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)
        return True

I tried this code but it doesn't work and the result is the same as before.

Okay, I tested it on my machine, and it seems that you need to use
instead of just refreshing the GUI. Apparently the change to the description through SetParameter does not suffice to inform C4D about a necessary redraw.

This works for me... now I just would like to know why it creates float fields for the 2nd to 4th "Add", but link fields for all others...

@Cairyn Thank you again for helping me.
Yep, SetDirty(c4d.DIRTYFLAGS_DESCRIPTION) works like a charm! :+1:

    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)
                node.SetDirty(c4d.DIRTYFLAGS_DESCRIPTION)  # This was needed!
        return True

I'm sorry but I'm not sure what you mean about float fields for 2nd to 4th "Add". On my end, my code adds link fields everytime user click the Add button.
Let me know if my understanding is wrong.

By the way, it is also worth mentioning the Note on MSG_CHANGE

@mp5gosu Oh I couldn't find that. Thank you for your heads up!

@beatgram I changed some parts of the code since I was wondering about a few details, so this may be solely on my side. Do you have a ttesttag.h file that you don't show, and a .str file? For my test, I created these files (plugin didn't start without). That may have created some differences.

@Cairyn Okay, here's my .h / .str files. Sorry, I should have shared these in the first post.


#ifndef _TTESTTAG_H_
#define _TTESTTAG_H_




    Ttesttag "Test Tag";

@beatgram Ah yes, that makes sense that these files exist. It doesn't explain the phenomenon though, since I chose precisely the same numeric values...

I believe C4D is doing something in the background with these files, otherwise you wouldn't be able to write c4d.TTESTTAG_LINKS_GROUP - this is not a constant that C4D defines, so somehow it is generated in the header parsing process. I suppose I need to look into that, although the original question has been answered now ;-)

@Cairyn Interesting investigation but it's a bit difficult for newbie like me. :face_with_rolling_eyes:
Anyway, I appreciate your help!

Hi @beatgram so far nothing to add from our side, what @Cairyn said is the correct way to proceed with node.SetDirty(c4d.DIRTYFLAGS_DESCRIPTION).

Regarding ttesttag.h and more generally about resources in Cinema 4D.
They are parsed during the startup of Cinema 4D, due to a bug currently if you change the content of the file it will not update it and you will need to update the symbolcache for more information about it see Dealing with Symbolcache.

However, I can't really explain why it was creating float description and not DTYPE_BASELISTLINK, if you are able to reproduce the issue please share the whole project so we can look at it. And except if you override the value of DTYPE_BASELISTLINK I don't see any valid reason for the Python symbol parser to produce the change.


@m_adam Thank you for confirming.
I already know symbolcache thingy, so it's no problem.

Hi with the latest update of Cinema 4D (R24 SP1),
any update to a description files should now be reflected correctly to the symbolcache files, so it's not needed to delete it manually anymore.


@m_adam Oh, that's a little update for many users but huge for tiny developers like me!
Thank you so much for the heads up. :flushed: