I am building a service to convert STEP files to STL files for user viewing. This conversion is just so the user can view the file uploaded to the server. It is not used to modify the file.
However, the tested conversion libraries can not efficiently convert from STEP to STL.
I first tried FreeCAD, and made the following forum post: https://forum.freecad.org/viewtopic.php?t=79333
How to install FreeCAD for scripting: https://forum.freecad.org/viewtopic.php?t=79327
For FreeCAD, the code goes as follows:
Part.open(fileNameFrom) # STEP File on server
Mesh.export( FreeCAD.getDocument("Unnamed").findObjects(), fileNameOut) # STL file on server
However, FreeCAD's process is so inefficient that a 22 MB STEP file outputs as a 366 MB STL file after two minutes of conversion. Even smaller-sized 500 KB files still produce an 18 MB file output, with no documentation specifying less resolution to reduce file size.
The next coding library I tried was cadquery
. The syntax and setup for a server is simplistic, as this library can be directly installed from PIP, unlike FreeCAD.
import cadquery as cq
afile = cq.importers.importStep(fileNameFrom)
cq.exporters.export(afile,fileNameOut)
Cad Query initially performed decent, producing an 8 MB output STL file for the same 500 KB STEP test file. However, the 22 MB STEP file was converted to a 386 MB STL file.
The STEP files were not complex enough to yield such file sizes. This is the 22 MB STEP file:
Here is the 500 KB STEP file:
What libraries can I try that can easily convert STEP to STL without large file sizes? It is preferred that the library is in Python or Node. However, Java or C++ are also acceptable; our team can work with such servers. I hypothesize C++ based libraries would have the best processing speed.