Wed, 09/20/2023 - 09:51
Hello everyone,
Using the inspector tool that comes with OCCT we can see that my test STEP file contains that label with an attribute name (see attachment 1).
If I use the next code, I'm unable to get "Grip of Hammer" as the attribute name:
if (label.FindAttribute(TDataStd_Name::GetID(), nameAttr)) {
TCollection_ExtendedString nameExtendedString = nameAttr->Get();
auto wStringName = nameExtendedString.ToWideString();
name = UtilsCli::ToString(wStringName);
return true;
}
But If I use the following code, then it works:
auto nameAttrId = TDataStd_Name::GetID();
auto iter = TDF_AttributeIterator(label);
while (iter.More())
{
auto attribute = iter.Value();
if (Standard_GUID::IsEqual(attribute->ID(), nameAttrId))
{
Handle(TDataStd_Name) nameAttr;
if (attribute->FindAttribute(nameAttrId, nameAttr))
{
TCollection_ExtendedString nameExtendedString = nameAttr->Get();
auto wStringName = nameExtendedString.ToWideString();
name = UtilsCli::ToString(wStringName);
return true;
}
}
iter.Next();
}
Is that any type of issue with the FindAttribute method?
In both methods I'm using the same label.
Seeing that this works:
attribute->FindAttribute(nameAttrId, nameAttr)
Could an attribute contain other attributes?
Best regards!
Lorenzo
Attachments: