Hi Author,
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,
Commenter-1
Archived discussion
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;
}
Discussion
Posts are displayed in their archived order.
Hi Author,
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,
Commenter-1
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,
Author
Hello everyone!
is there nobody who made something like this in the past? I would be very grateful!
Best regards, Author
Hi Author,
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, Commenter-1
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.
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,
Commenter-1
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...
Commenter-2.
Hi Guido,
Thanks for your reply.
I will follow your recommend.
BR,
Commenter-2