flag a tag so that it can be dstinguished



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/01/2008 at 15:38, xxxxxxxx wrote:

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

    ---------
    OK, last question (for today). Promised!

    I create texture tags for objects with a plugin. Every time the user clicks on a button, a new texture tag is created for the active object.

    At some point in my plugin, I need to retrieve all of these texture tag and ONLY the ones that I created with the plugin, not the ones that the user created by creating a new material.

    So, can I flag my texture tags in a way so that they are distinguishable from the 'normal' texture tags?

    (What I did is this. I create a material + tag. Assign the material to the tag and give it a special name. When I want to retrieve all my tags, I loop through all the tags and look if it is linked to a material with this special name. Pretty complex, no?)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 17/01/2008 at 10:21, xxxxxxxx wrote:

    You can use the 'special name' (this is what I do in particular circumstances).

    Or you can create an AtomArray and store your tags in it as they are created. Think of this class as a dynamic array for storing C4DAtom-derived elements (most of the Cinema 4D elements are).

    AtomArray* tagArray = AtomArray::Alloc();
    if (!tagArray) // bad tagArray, bad! :)
    ...
    // a new texture tag 'texture' was created by your plugin
    tagArray- >Append(texture);
    ...
    // access the tagArray elements like this:
    TextureTag* tag;
    LONG tACnt = tagArray->GetCount();
    for (LONG i = 0L; i != tACnt; ++i)
    {
         tag = static_cast<TextureTag*>(tagArray->GetIndex(i));
    ...
    }
    ...
    // Don't forget to free the tagArray at some time
    AtomArray::Free(tagArray);

    If you are going to reuse this AtomArray for different objects or at different times collect other texture tags, just call tagArray->Flush() to reset the elements to which it points.


Log in to reply