How to add a tag to an object

  • On 01/06/2013 at 21:13, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R14 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    How do I add a tag to an object? I have no problems cloning tags, like this.

    BaseTag* tagFound = someObject->GetFirstTag();
    BaseTag* newTag = (BaseTag* )tagFound->GetClone(COPYFLAGS_0, NULL);
    anotherObject->InsertTag(newTag, NULL);

    But how do I 
    a) Insert one of the C4D built in tags, like the Constraint tag
    b) Insert one of my own tags.
    For (a) I just do not know. For (b) I get error messages. Mainly because my tags are

    class MySpecialTag : public TagData

    and I get complaints about  MySpecialTag not being a BaseTag*.

    Any ideas?

  • On 02/06/2013 at 00:11, xxxxxxxx wrote:


    BaseTag* tag = BaseTag::Alloc(Tcaconstraint);  
    if (tag) obj->InsertTag(tag, NULL);  

    You will need to include the modules/ca/res in your search path and include "Tcaconstraint.h" in order to have the enumeration.


    BaseTag* tag = BaseTag::Alloc(MYPLUGIN_ID);  
    if (tag) obj->InsertTag(tag, NULL);  

  • On 02/06/2013 at 02:48, xxxxxxxx wrote:

    You can have it even easier:

    BaseTag *tag = obj->MakeTag(Tcaconstraint);   

    This will allocate and insert the tag in one single call. Don't forget to check the result for NULL, though.

  • On 02/06/2013 at 03:45, xxxxxxxx wrote:

    Well, I think that I have had issues with adding undos using MakeTag().  But if that behavior has changed, by all means use that instead.

  • On 02/06/2013 at 03:49, xxxxxxxx wrote:

    Thanks a whole bunch! I will test it out, as soon as I have sorted out a few other issues. And Undo is important, yes.

Log in to reply