For all issues regarding the Forums use, please, refer to the Forum Rules.

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

Related pages

Reading Geometry from step files

Flo Hup's picture
Forums: 

Hello everyone

I need to read simple step files (turning parts) with C++. Therefore I try to use Open Cascade. I already can open my step file and read the number of shapes in my file. Now I need to get the geometrical data (length, width, diameters..), but I dont know how it works, although I read all of the documentations. Is there anyone who already worked with Open Cascade and can help me with my Problem? I would be very happy, thanks alot !!

That's my Code since then


#include <iostream>

#include <STEPControl_Reader.hxx>

#include <string>



using namespace std;





int main() {



STEPControl_Reader reader;

IFSelect_ReturnStatus stat = reader.ReadFile("C:\\Users\\Kelevradesktop.Kelevra-desktop\\Desktop\\Studienarbeit\\linkrods.step");

IFSelect_PrintCount mode = IFSelect_ListByItem;

reader.PrintCheckLoad(false, mode);



Standard_Integer NbRoots = reader.NbRootsForTransfer();                      //Transfer whole file

Standard_Integer num = reader.TransferRoots();



Standard_Integer NbTrans = reader.TransferRoots();

TopoDS_Shape result = reader.OneShape();

TopoDS_Shape shape = reader.Shape();



cout << NbRoots << endl;

cout << NbTrans << endl;

cout << num << endl;



system("pause");



return 0;

}

Guido van Hilst not specified's picture

Hi Flo,

Here is an example to read shapes from stepdata: ShapeFromStep

It is an example in C# but you can use the same in C++.

Hope it helps, best regards,

Guido 

Flo Hup's picture

Hi Guido, thank you very much for your answer. I cant find the methods used in your example in the OpenCascade library. Is it made with this library? I am not highly skilled in programming, sorry for maybe some stupid questions.

Best regards,

Flo

Flo Hup's picture

Hello everyone!

is there nobody who made something like this in the past? I would be very grateful!

Best regards, Flo

Guido van Hilst not specified's picture

Hi Flo,

Any succes on reading step-files?

Yes the example I gave are in C#, and some extension-methods are used for convenience.

If you remove the "OC" prefix from the C# class-names, it is the same name as the occ C++ classes. (it should not be to difficult to make the same example in C++)

Best regards, Guido

Bill Chen's picture

Hello Guido,

I have follow your instruction to remove prefix  OC, but I can not to find ReadText funcyion.

and checked  STEPCAFControl_Reader.cxx file also no this function,

I don't know what problem ,could you help me?

Thanks.

Guido van Hilst not specified's picture

Hi Bill,

OCSTEPCAFControl_Reader.ReadFromText(string txt) Is an extension method.

It creates a temp file, write the text to the temp file , then reads the file and deletes the temp file.

unfortunately OCSTEPCAFControl_Reader cannot read directly from string or stream.

 Best regards,

Guido

Bill Chen's picture

Hi Guido,

Thanks for your reply.

I will follow your recommend.

BR,

Bill Chen

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.