How does tcaconstraint add/remove groups?

  • On 04/03/2018 at 03:07, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R17 
    Platform:    Mac  ;  
    Language(s) :     C++  ;

    Greetings to all.

    I'm trying to write a plugin that needs to be able to add and remove groups of elements on demand (whenever the user presses a button), kinda like the way the character constraint tag works with the PSR and Aim sections.

    I know this has something to do with GetDDescription(), but I'm not entirely clear on how. I believe GetDDescription needs to construct the entire "dynamic" portion of the UI every time it's called (as that information isn't saved anywhere), which is fine. However, I'm not clear on a couple of things, and I was hoping someone could help me with.

    1. How do you use GetDDescription() with an existing *.res file? The majority of my plugin is defined by the resource file, however I only need to add and remove groups from one specific section of the UI. I'm assuming I need to tell C4D to load the res file contents somehow- but after I do that, how do I specify where my dynamic description stuff should show up? Is that simply a matter of inserting the elements at the right place (after C4D has presumably loaded up my stored descriptions from the res file)?

    2. I noticed the tcaconstraint tag seems to store a bunch of "template" widgets in the *.res file that are declared as hidden by default; yet they seem to match the layout of the elements that get cloned when the user clicks the add button. Why is this? Is the tag simply copying those hidden elements, unhiding them, and adding them to the description passed to GetDDescription()?

    3. How do I handle the description IDs for dynamically added elements? Should I just start at some base integer (like 2000) and add a specific number to that for each dynamic group? Ie, group 1 would start at 2000, group 2 would start at 2010, group 3 at 2020, etc, etc.

    4. How should I be storing the data associated with the dynamic widgets? Normally I just grab a pointer to the base container provided by node->GetDataInstance() and get/set stuff through there. When the user clicks the "add" button, should I just store some arbitrary data in there (presumably matching the IDs of the elements as laid out in #3) and then assume that my code in GetDDescription will automatically retrieve that data and use it to display the relevant data? Or is there some other way I should be saving and loading this stuff to the scene somehow?

    Sorry if my terminology is kinda broken here... I have written plugins before, but I've never had a reason to get down and dirty with the description system (all my former plugins have static GUIs). Trying to create a dynamic UI has exposed me to a lot of things I'm not quite familiar with.


  • On 05/03/2018 at 01:53, xxxxxxxx wrote:


    First of all I would like to point you to GetDDescription Manual, Description Manual and objectdata_descriptions example.
    Pretty much everything you asked is explain in theses manuals or object_data_example.

    If not please do not hesitate to ask more informations.


Log in to reply