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

Search the Forums
See All Topics

Extracting entity names from STEP Files

Extracting entity names from STEP Files
Bayard 2012/07/23 13:30
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 (

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 <= nb; 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 2012/07/24 13:29
I've found the solution, I can access to the WS by the method STEPCAFControl_Reader::Reader().
Warren Couvillion 2012/09/14 00:30
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 2012/11/09 15:34
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 2012/09/10 22:40
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 2012/09/11 11:12
Dear Warren,
Very probably you forgot include library TKSTEPBase,
which contains the referred API.
Warren Couvillion 2012/09/11 20:35
Thanks! That was the problem. I had to include it in more than just the project I was working on, though.     
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