
Mon, 05/30/2016 - 13:00
Hi.
I try to access the attribute of assembly tree of XDE.
I can get names of assembly or component but I can't get centroid.
Here is my code.
Please help me.
STEPCAFControl_Reader reader;
IFSelect_ReturnStatus stat = reader.ReadFile("filename");
Handle(TDocStd_Document) aDoc;
Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
anApp->NewDocument("MDTV-XCAF", aDoc);
if (!reader.Transfer(aDoc)) {
std::cout << "Cannot read any relevant data from the STEP file" << endl;
// abandon ..
}
Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
TDF_LabelSequence labelSequence;
myAssembly->GetShapes(labelSequence);
for (int i = 1; i <= labelSequence.Length(); i++)
{
const TDF_Label& label = labelSequence.Value(i);
TopoDS_Shape S = myAssembly->GetShape(label);
Handle(TDataStd_Name) name;
if (label.FindAttribute(TDataStd_Name::GetID(), name))
{
TCollection_ExtendedString extstr = name->Get();
}
gp_Pnt pos;
Handle(XCAFDoc_Centroid) C;
if (label.FindAttribute(XCAFDoc_Centroid::GetID(), C))
{
pos = C->Get();
}
}
Tue, 05/31/2016 - 08:19
Sorry, I complete it myself.
Sun, 10/03/2021 - 10:58
Hi Yu Nakane,
Can you please post the snippet of your code?