On 13/11/2017 at 06:10, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R19
Platform: Windows ;
Language(s) : C++ ;
---------
I am using a TagData to store information for an object.
There is a reason why i don't store this information into a container in the object itself, but out of scope of this question.
I would like -inside of the tag plugin- to use GetObject() to obtain the object the tag was assigned to.
But I haven't found a way for the TagData to know when the tag is being added to the object.
At time of TagData::Init the GetObject returns a nullptr since the tag is not yet assigned.
In a scenehook I have noticed I can do following in Message() :
if (type == MSG_DOCUMENTINFO)
{
DocumentInfoData* did = static_cast<DocumentInfoData*>(data);
if (did && (did->type == MSG_DOCUMENTINFO_TYPE_TAG_INSERT))
{
BaseTag* tag = static_cast<BaseTag*>(did->bl);
...
At this point the tag is assigned to the object and I can thus get the object from:
tag->GetObject();
I would prefer to do so in the TagData itself, but the message isn't sent to the TagData.
Is there any method which gets called (or message sent) to indicate the tag is assigned to an object.
I am not using the Execute() method of the TagData, as this gets called more than once during the lifetime of the tag. Should I focus my effort on this method to be triggered with the appropriate object, and keep some state to only handle this once? Or is there a better way to get notified when the object is available to the tag instance?
Thanks.