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

Extracting entity names from STEP Files

Bayard's picture

Hello !
I've seen some things about this subject on forums but not exactly answering to my question. I want to extract STEPRepr_RepresentationItem names from STEP File created (in a first time...) in Rhino, and it seems natural for me to use OCAF and XDE. I've read that it was not provided by XCAF (http://opencascade.wikidot.com/entitynames).

My idear was to create a sub class "STEPCAFControl_ReaderBis" of STEPCAFControl_Reader, with a method "ReadNamesBis", which could do the same things for StepRepr_RepresentatonItem names than "STEPCAFControl_Reader::ReadNames" for product names.

The problem is that the property aReader of STEPCAFControlReader is private and that I can't access to the XSControlWorkSession in my class, then I could'nt access to the work session. Does anyone has an idea ?
Thank you very much !

Standard_Boolean ReadNamesBis(const Handle(XSControl_WorkSession)& WS,
Handle(TDocStd_Document)& doc)
Handle(Interface_InterfaceModel) Model = WS->Model(); // Is there any way to access to the WorkSession
Handle(XSControl_TransferReader) TR = WS->TransferReader();
Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( doc->Main() );
if ( STool.IsNull() ) return Standard_False;
Standard_Integer nb = Model->NbEntities();
Handle(TCollection_HAsciiString) name;

for (Standard_Integer i = 1; i Handle(Standard_Transient) enti = Model->Value(i);

if ( ! enti->DynamicType()->SubType("StepRepr_RepresentationItem")) continue;
Handle(StepRepr_RepresentationItem) SRRI =
Handle(TCollection_HAsciiString) hName = SRRI->Name();
TCollection_ExtendedString myName ( hName->String() );

Handle(Transfer_Binder) binder = TP->Find( enti);
if ( binder.IsNull() || ! binder->HasResult() ) continue;

TopoDS_Shape S = TransferBRep::ShapeResult ( TP, binder );
if ( S.IsNull() ) continue;

TDF_Label shL;
if ( ! STool->Search ( S, shL, Standard_True, Standard_True, Standard_True ) ) continue;
return Standard_True;

Main Function :
STEPCAFControl_ReaderBis aReader;
IFSelect_ReturnStatus status = aReader.ReadFile(aFileName);
if (status != IFSelect_RetDone)
return status;

Bayard's picture

I've found the solution, I can access to the WS by the method STEPCAFControl_Reader::Reader().

Warren Couvillion's picture

As mentioned, I'm trying to implement this so I can map names to shapes. I'm reading in the STEP file with a STEPCAFControl_Reader. When iterating through the entities, I check that each entity is a StepRepr_Representation, and then try to bind it using

Handle(Transfer_Binder) binder = tp->Find(ent);

where tp is the const Handle(Transfer_TransientProcess)&

binder.IsNull() returns true every time. I know the STEP files are good, as I've read them in and displayed them without trying to get names. I also know that there are named entities, because I used to check for names first, and that check passed.

What am I missing about the binder?

Hennig's picture

hello warren,
did you find a solution with your binder problem? i read my step file with a stepcontrol_reader. im also sure that the file is correct and checked the names before.

But binder.IsNull() returns true every time.

Thanks for help.

Warren Couvillion's picture

I've been trying to add this functionality to the MFC HLR sample. This line of code:

Handle(StepRepr_Representation) ent =

yields this linker error:

error LNK2001: unresolved external symbol "public: static class Handle_StepRepr_Representation __cdecl Handle_StepRepr_Representation::DownCast(class Handle_Standard_Transient const &)" (?DownCast@Handle_StepRepr_Representation@@SA?AV1@ABVHandle_Standard_Transient@@@Z)

Does anybody know which library I need to add?

Forum supervisor's picture

Dear Warren,
Very probably you forgot include library TKSTEPBase,
which contains the referred API.

Warren Couvillion's picture

Thanks! That was the problem. I had to include it in more than just the project I was working on, though.