Tue, 09/24/2024 - 09:59
I got a assembly .step file and i want save a part of them.
My code:
void GetAssemblyShapes(const TDF_Label& label, std::vector
if (XCAFDoc_ShapeTool::IsAssembly(label)) {
for (const TDF_Label& child : shapeComponents(label,aShapeTool))
GetAssemblyShapes(child, vecAssemblyShapes,aShapeTool);
}
else if (XCAFDoc_ShapeTool::IsReference(label)) {
TDF_Label referred;
XCAFDoc_ShapeTool::GetReferredShape(label, referred);
if(XCAFDoc_ShapeTool::IsAssembly(referred)){
TDF_LabelSequence atestLabels;
XCAFDoc_ShapeTool::GetComponents(referred,atestLabels);
for (TDF_LabelSequence::Iterator cRootIter(atestLabels); cRootIter.More(); cRootIter.Next())
{
GetAssemblyShapes(cRootIter.Value(), vecAssemblyShapes,aShapeTool);
}
}
}
Handle(TDocStd_Document) ok = ReadSTEPToDocument(fileloc);
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(ok->Main());
TDF_LabelSequence aRootLabels;
aShapeTool→GetFreeShapes(aRootLabels);
std::vector
GetAssemblyShapes(aRootLabel, vecShapelabels,aShapeTool);
STEPCAFControl_Writer mywriter;
mywriter.SetColorMode(true);
mywriter.Transfer(alabel);
When i use XCAFDoc_ShapeTool::GetComponents(referred,atestLabels); and save them to .step.I get wrong location part,i want to know how to save right when the label IsReference.
Tue, 09/24/2024 - 15:30
Hello, what means "wrong location"? Saving only reference always ignore any high level transformations. It means element will be located in the (0,0,0) position with identity matrix. If you want to change to the the same position as in the scene, you need to update something manually. For now it is not supported by default.
Best regards, Dmitrii.
Sun, 09/29/2024 - 06:38
thanks,so how can i add a transformation in a TDF_Label