Notifications
Clear all

[Closed] SDK : Accessing custom attribute definition name

Hello,
I would need to access the def name of a custom attributes but I can figure out how to do it. I only found how to access its name.

Here is the custAttribs array of the object I process. The name I want to get is “Lightmap CA”.

#CustAttribs(Lightmapped Object CA:Lightmapped Object, Lightmap CA:maisons1)

I used that function but it works only when both atribute “def name” and name are matching :

CustAttrib* CustomAttributesEvaluator::GetCustomAttribute (INode* node, const TCHAR* caDefName)
{
   ICustAttribContainer* p_attrContainter = node->GetCustAttribContainer();
   if( p_attrContainter )
   {
      int numCAs = p_attrContainter->GetNumCustAttribs();
      for( int i=-1; ++i<numCAs; )
      {
         CustAttrib* p_attr = p_attrContainter->GetCustAttrib( i );
         const TCHAR* currentAttribName = p_attr->GetName();   // gives me "maisons1", not "Lightmap CA"
         if ( _tcsicmp( currentAttribName, caDefName) == 0 )
         {
            return p_attr;
         }
      }
   }
   return NULL ;
}

Thanks in advance, guys !

2 Replies

sorry i was talkin rubbish

I didn’t see your post.
Finally I got it working by testing the attribute ClassID to be sure I am getting the right attribute.

CustAttrib* CustomAttributesEvaluator::GetCustomAttribute (INode* node, const Class_ID caID)
{
   ICustAttribContainer* p_attrContainter = node->GetCustAttribContainer();
   if( p_attrContainter )
   {
      int numCAs = p_attrContainter->GetNumCustAttribs();
      for( int i=-1; ++i<numCAs; )
      {
         CustAttrib* p_attr = p_attrContainter->GetCustAttrib( i );
         if ( p_attr->ClassID() == caID )
         {
            return p_attr;
         }
      }
   }
return NULL ;
}

But still, I ask myself how to get this definition name from a CustAttrib…