more tags

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

On 06/05/2005 at 06:26, xxxxxxxx wrote:

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

---------
Hi,
Only one instance of my plug (tagData) is allowed per doc.
Is there a way to find out if there exist more instances of it ?
regards,

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

On 06/05/2005 at 08:28, xxxxxxxx wrote:

Hi,

you could check each tag on an object, and count them

  
tag->GetType()==TAG_PLUGIN_ID  

should work for checking if it's your tag.

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

On 06/05/2005 at 09:30, xxxxxxxx wrote:

Seems the only way to do this is to get your BaseDocument, go through the object hierarchy, and check each object for the tag (skipping the one that should contain the tag).

  
BaseDocument* doc = GetActiveDocument();  
BaseObject* obj = doc->GetFirstObject();  
BaseObject* myObj; // contains valid tag  
void CheckFormyTag(obj, myObj);  
  
void CheckFormyTag(BaseObject* obj, BaseObject* myObj)  
{  
     for (obj; obj; obj = obj->GetNext())  
     {  
          CheckFormyTag(obj->GetDown(), myObj);  
          if (!obj->GetTag(ID_MYTAG_PLUGIN)) continue;  
          if (obj == myObj) continue;  
          // Otherwise, there is another of your tags on another object  
          ...  
     }  
}  

ETA: You could temporarily remove the valid-tag object before doing this check and reinsert afterwards - making certain to retain its parent for proper reinsertion. Then you wouldn't need to send it through the recursive function and check each object against it.

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

On 06/05/2005 at 14:59, xxxxxxxx wrote:

Hi,
Thanks both.
I will try and let you know.

regards,