![Flo Hup's picture Flo Hup's picture](/sites/default/files/images/userpic_default.png)
Wed, 07/04/2018 - 13:44
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;
}
Thu, 07/05/2018 - 13:48
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
Fri, 07/06/2018 - 14:13
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
Mon, 07/09/2018 - 14:23
Hello everyone!
is there nobody who made something like this in the past? I would be very grateful!
Best regards, Flo
Fri, 07/13/2018 - 11:14
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
Tue, 01/01/2019 - 17:42
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.
Wed, 01/02/2019 - 17:31
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
Thu, 01/03/2019 - 15:15
Hi Guido,
Thanks for your reply,
Your web sit has showed a CShape example, Is it for WEB ?
http://www.creativecadtechnology.com/OCC/ShowScript?userName=shapefromst...
Bill Chen.
Fri, 01/04/2019 - 09:22
Hi Guido,
Thanks for your reply.
I will follow your recommend.
BR,
Bill Chen