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 STEP file in OCCT

Shamsher's picture
Forums: 

Hi All,

 I am using OCCT with Qt on Linux. I am trying read STEP file, but unable to do so.

I have tried

STEPControl_Reader Reader;
    Reader.ReadFile(;valve.stp;);
    Reader.TransferRoots();
    TopoDS_Shape shape = Reader.OneShape();

and

Standard_Integer main()
{
  STEPControl_Reader reader;

  Reader.ReadFile(;valve.stp;);
    Reader.TransferRoots();
    TopoDS_Shape shape = Reader.OneShape();
}

Any Clues /

Thanks In advance

Laszlo Kudela's picture

Hello Shamsher,

do you get a segmentation fault, or "TopoDS_Shape shape" does not contain the shape that you expect? Your code should work as far as I can tell.

Can you maybe send the STEP file (or similar) that you are trying to read?

László

Shamsher's picture

Hi Laszlo,

Actually I took the sample from https://github.com/eryar/occQt/

and I was able to run the samples. After that I created a model in Solidworks and saved as STEP file.

Please find the attached files for further clarification.

Thanks

Attachments: 
Laszlo Kudela's picture

Hey

I could read in the file. Should it look like the screenshot attached?

Looking at your code, probably the error is in line 216, where you specify the file name.  The name should be put between quotation marks, as it should be a string. Like this:

reader.ReadFile("valve203.stp");

Does this help?

László

Laszlo Kudela's picture

Actually, it should be called "valve203.STEP", I just realized the file extension was wrong in my reply.

Shamsher's picture

Hi,

I could read the file but unable to display it like the image you have posted above.

Could you let me know how to display ( sample code ) the model present in STEP file.

warm regards,

shamsher

Shamsher's picture

Got it. Working fine.

Now can you help me with which library/header file I need to add to modify part or assembly files ?

Thanks

Laszlo Kudela's picture

Hello Shamsher,

it depends on what you would like to achieve. Opencascade provides many functions to perform geometric and/or topologic operations. I suggest that you check out the documentation of Opencascade fur further details. There are also some blogs discussing certain aspects, such as:

-Roman Lygin's blog http://opencascade.blogspot.de/

-Sebastien Raymond's Opencascade recipes https://neweopencascade.wordpress.com/

-A small tutorial series written by me, it is still under construction: https://occtutorials.wordpress.com/ with a GitHub repository here https://github.com/lvk88/OccTutorial

If you tell me what exactly you would like to do, maybe I can give further hints.

László

Shamsher's picture

Hi Laszlo,

Your tutorial is nice piece of work.

Apart from that, I have already checked links sent by you but I am unable to find any solution to my problem.

I have an assembly in STEP format. I want to extract/access the components and modify them in OpenCascade.

Please find the attached file for assembly.

Thanks

Shamsher

Attachments: 
Laszlo Kudela's picture

Hello Shamsher,

I am not sure what you mean by "modify" - there are many ways to "modify" a geometric model. Do you want to rotate it, scale it, mirror it, make a hole in it, convert it to a different representation,etc...?

Maybe you could explain a bit more what you would like to do, like before/after picture, so that we would get a better idea on what is your exact plan.

László

Shamsher's picture

Hi Laszlo,

Sorry for confusion.

Actually I want to perform rotation and scaling on the individual components in an assembly.

PFA attached images.

Shamsher

Laszlo Kudela's picture

Hey Shamsher,

thanks, now I understand what you would like to do. I wrote a sample code for you that should do more or less what you need. Check it out here:

https://github.com/lvk88/OccTutorial/blob/master/OtherExamples/runners/moveAndRotateAssem.cpp

I tried it with your file, it should produce a result like the one in the screenshot.

Shamsher's picture

Hello Laszlo,

Thanks for your help.

Your approach works fine for small assemblies (components <= 10), but for large assemblies it is very difficult to identify the components and hence performing any operation/modification on desired component is  tedious task.

Is it possible to identify the components in graphics window so that user can quickly perform modifications on desired component ? (maybe like a tooltip or something)

Regards

Shamsher

Rahman Abber Tahir's picture

Hi guys,

Can you please share the code to read and display .step file in opencascade?

I need it urgently

​Thanks

Forum supervisor's picture

Hello Rahman,

For STEP translation and displaying, you might consult the source code of the standard Import Export sample of Open CASCADE Technology.

See the folders .\samples\mfc\standard\05_ImportExport and .\samples\mfc\standard\Common\ImportExport of the Open CASCADE Technology installation.

Best regards,

Forum supervisor

Jose Urbano's picture

Hello everybody,

I am interested in a similar application of OCC. I want to program a reverse engineering methodology. I have a nominal part (STEP) and a 3d scan (STL). I want to fit the STL file to the parameters of the STEP file. I have thought on the following steps.

1. I want to load de topology and geometry of the STEP file into OCC. I want to have access to each surface and position of the nominal geometry. 

2. One I have that information, I will know where to perform a least-squares fitting in the STL file.

3. With the knew parameters, I would like to rewrite a knew version of the STEP file.

I have seen in the documentation that there exist many classes and methods that would be able to solve this task. I am very knew in this program and I will appreciate any support that you can give me.

Thanks!

Jose

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.