Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics

How to Extract entity names or features from step file and express to xml file.

How to Extract entity names or features from step file and express to xml file.
Fong Heng 2012/11/19 12:07
Hi everyone,
This is a first time that i use the open cascade and i want to ask everyone how to Extract entity names or features from step file and express to xml file? one more what is a shapeName from this parameter in this function and how can i get it? hope can anyone help me:

TopoDS_Shape getShape(char* shapeName,STEPControl_Reader reader)
const TCollection_AsciiString ascShapeName(shapeName);

               const Handle(XSControl_WorkSession)& theSession = reader.WS();
const Handle(Interface_InterfaceModel)& theModel = theSession->Model();
const Handle(XSControl_TransferReader)& aReader = theSession->TransferReader();
const Handle(Transfer_TransientProcess)& tp = aReader->TransientProcess();

Standard_Integer nb = theModel->NbEntities();
TopoDS_Shape retShape;
for(Standard_Integer i=1; i<=nb; i++)
Handle(StepRepr_Representation) ent =

if (ent.IsNull()) continue;
Handle(Transfer_Binder) binder = tp->Find(ent);
if (binder.IsNull()) continue;
TopoDS_Shape oneShape = TransferBRep::ShapeResult(binder);
if (oneShape.IsNull()) continue;

if (ent->Name().IsNull())

retShape = oneShape;

return retShape;

thank in advantage.
Hennig 2012/11/22 19:12
Hallo Fong
When you open the step file in an editor a face will look like:     

#17 = ADVANCED_FACE('IAmAFace',(#18),#32,.T.);

You can call your function now: getShape('IAmAFace') and it will return the shape belonging to this Name. But before you have to set your reader:

STEPControl_Reader reader;

Hope i could help. And is this function working in your case?

Ear MongHeng 2012/11/23 09:39
Thank for explain.

onemore after i get shape object(TopoDS_Shape myshape = getShape("iAmAFace")), how to get value and string like(#18,#32,T,ADVANCE_FACE) or what should i do next? can you explain more and how to use shape object after get it. i don't my question is it right or worry?

Thank again in advance. from cambodia student.
Hennig 2012/11/28 12:00

to get the other informations is not easy. depend on what you want to do after. for example a information about the kind of shape you get with myShape.ShapeType().

And with the shape Object you can do nearly everything, what OCC offers. You can project, intersect or split ist. Whatever you want. For some operations you have to get the geometry from the shape.

read the following blog. its really good for startin with OCC:


Ear MongHeng 2012/11/30 19:22
Thank for reply.
Latest news
  • Open CASCADE CAD Assistant for iOS platform is available!
  • Open CASCADE Technology 6.9.0 is available for download!
  • JT Assistant for Android

  • © OPEN CASCADE 2000 - 2015  |  Search  |  Contacts   |  Site map