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

Write to STL

Dominik Mokris's picture

Hello everyone,

a very basic question. I am learning to import a STEP file and export it to STL. I modified Laszlo's code from
as follows:

int main(int argc, char *argv[])
    STEPControl_Reader reader;
    TopoDS_Shape stepShape = reader.OneShape();
    StlAPI_Writer STLwriter;
    return 0;

However, when I run

./main valve203.STEP out.stl

(the valve file was posted here some time ago and is also attached), the result is more or less empty; it says only:

solid shape, STL ascii file, created with Open CASCADE Technology
endsolid shape

What's wrong? Certainly I am missing something very basic.

qa qa's picture


The step file itself does not contain any mesh. You should create it before saving manually. It can be done using BRepMesh_IncrementalMesh functionality.

qa qa

Dominik Mokris's picture

I see, apparently I misunderstood the phrase "Converts a given shape to STL format" from the documentation, because I thought that this included meshing.

Anyway, using the BRepMesh_IncrementalMesh turned out to be surprisingly simple.

Thank you very much. Without your help I would be unlikely to understand what was wrong in a finite time!


Dominik Mokris's picture

One more issue.

Say I want to import a STEP file such as as1-oc-214.stp (which one can obtain e.g. at ).
When I open it in FreeCAD, it consists of 18 parts.
However, when I import it with OpenCascade, it is just one big body.
What am I doing wrong?
I've already tried various combinations of "read.step.shape.repr", "read.step.assembly.level", etc., but without much success.

My code:

STEPControl_Reader reader;
Handle(TColStd_HSequenceOfTransient) list = reader.GiveList();
std::cout << list->Length(); // Prints "1", I would like something like "18".

Thank you very much!

Dominik Mokris's picture

Solved, apparently I had to use STEPCAFControl_Reader and more involved code, similarly to an older thread .

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.