Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

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

Ear MongHeng's picture

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 {
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's picture

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's picture

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's picture


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: http://opencascade.blogspot.co.at/2009/02/topology-and-geometry-in-open-cascade.html


Ear MongHeng's picture

Thank for reply.