jianbaoxia
CAD master
Hi Bros, I get a face's annotation of a step entity.
Just like this:
#17 = ADVANCED_FACE('233',(#18),#32,.F.);
I get the "annotation ": 233. (I don't know it's term, and just call it "annotation ")
I get the annotation through class StepRepr_RepresentationItem.
And there is my code:
Now, there is my question, how to set the annotation and save it in .step file.
Actually, I can use the StepRepr_RepresentationItem.SetName() to set the annotation, however, it didn't saved in .step file.
The scenes is that I make a box through BRepPrimAPI_MakeBox, so I get the box's TopoDS_Shape, and then I will save it to box.step.
Meanwhile, I want to set the annotation for every face, I have no idea how to complete it.
Just like this:
#17 = ADVANCED_FACE('233',(#18),#32,.F.);
I get the "annotation ": 233. (I don't know it's term, and just call it "annotation ")
I get the annotation through class StepRepr_RepresentationItem.
And there is my code:
Code:
std::string filepath = "C:\\Users\\14656\\Desktop\\Program\\Open Cascade\\Demo_LRH\\build\\box_hole.step";
//! 1、
STEPControl_Reader reader;
//! 2、
reader.ReadFile(filepath.c_str());
//! 3、
reader.TransferRoots();
//! 4、
TopoDS_Shape shape = reader.OneShape();
Handle(XSControl_TransferReader) treader = reader.WS()->TransferReader();
for (TopExp_Explorer exp(shape, TopAbs_FACE); exp.More(); exp.Next())
{
TopoDS_Shape face = exp.Current();
Handle(Standard_Transient) entity = treader->EntityFromShapeResult(face, 1);
Handle(StepRepr_RepresentationItem) repre = Handle(StepRepr_RepresentationItem)::DownCast(entity);
if (!repre.IsNull())
{
if (!repre->Name().IsNull())
{
std::string name = repre->Name()->ToCString();
std::cout << name<< std::endl;
}
}
}
Now, there is my question, how to set the annotation and save it in .step file.
Actually, I can use the StepRepr_RepresentationItem.SetName() to set the annotation, however, it didn't saved in .step file.
The scenes is that I make a box through BRepPrimAPI_MakeBox, so I get the box's TopoDS_Shape, and then I will save it to box.step.
Meanwhile, I want to set the annotation for every face, I have no idea how to complete it.