Wed, 05/22/2024 - 13:25
Hello, I ues the sample given in the "New feature - STEP Import | User Defined Attributes", code as:
Handle(TDocStd_Document) aDoc = new TDocStd_Document("MDTV-XCAF");
Standard_CString filename = "E:\WorkSpace\metadataFile.stp";
STEPCAFControl_Reader reader;
reader.ReadFile(filename);
if(reader.Transfer(aDoc)){
std::cout << "Translate successful\n";
}else{
std::cout << "Translate failed\n";
}
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
NCollection_IndexedDataMap<TCollection_AsciiString, Handle(TDataStd_NamedData)> aNameDataMap; // Container to keep label's entry and its metadata
for (TDF_ChildIterator anIter(aShapeTool->Label(), Standard_True); anIter.More(); anIter.Next())
{
const TDF_Label& aLabel = anIter.Value();
TCollection_AsciiString anEntry;
TDF_Tool::Entry(aLabel, anEntry);
Handle(TDataStd_NamedData) aNamedData = aShapeTool->GetNamedProperties(aLabel);
if (!aNamedData.IsNull())
{
aNameDataMap.Add(anEntry, aNamedData);
}
}
But it falied while using the transfer() function.
How to translate a stp file to document for parsing UDA data?
Any help is greatly appreciated. Thank you!
Wed, 05/22/2024 - 14:03
Hello, We need to have step file to help you. But us for Transfer error should be not related with UDA. Additionally please turn on the reader.SetMetaMode(true).
Could you share STEP file?
Best regards, Dmitrii.
Thu, 05/23/2024 - 04:52
Hello Dmitrii,
I paste the STEP file and my simple test code. Thank you for your help.
Thu, 05/23/2024 - 11:50
Firstly, your file have no any metadata. Additionally, there are no issue with read process. Your path is incorrect, \s means digital presentation of symbol, needs to use /s.
Please use: "E:/WorkSpace/metadataFile.stp";
Best regards, Dmitrii.
Thu, 05/23/2024 - 13:53
Thank you Dmitrii!
Now I can read the STEP file.
Yes, you are right, i mess up the definition of UDA data, and I check the STEP file again, this file do not include metadata. And I upload a new STEP file. I think this file might be right. So can i read the UDA data as shown in the picture?
Best regards, Elle.
Thu, 05/23/2024 - 14:39
Well, yes, theoretically you can extract, but this file has no UDA. Only view and material.
So, you need to find another file with UDA.
for example from ticket: http://davidemercanti.altervista.org/sources/1M001934.stp
Best regards, Dmitrii.
Fri, 06/07/2024 - 06:34
Hi Dmitrii,
Thank you so much for your generous assistance. I'm pleased to inform you that I am now able to read the STP file using OCC 7.8. I insert UDA failed while using other softwares, that's why my stp file has no UDA. Your help has been invaluable in resolving these issues. Once again, thank you tremendously for your support.
Best regards,
Elle