STL to STEP File Converter

How STL to STEP Conversion Works

3D Icon
STL vs STEP and Why?
3D Icon
STL File Structure: Triangles
3D Icon
Building Faces: Adjacency and Coplanarity
3D Icon
Tessellation: Building Curvature
3D Icon
Solid Geometry: STEP File Structure
3D Icon
Programming and Lessons Learned

STL vs STEP and why

STL and STEP files are ubiquitous CAD file types used for design, manufacturing, and simulation.

STL Files

  • Similar to pointclouds, list of points/triangles which form shapes
  • May or may not be topologically sound
  • Designed with minimal information/file size for 3d printing, not for editing

STEP Files

  • Precise representations of manifold 3d geometry including validation
  • Ubiquitous across software/application (ISO 10303-21)
  • Straightforward editing/improvements

STEP, and other solid geometries, are easily converted to STL for 3d printing or other applications. No robust converter exists to rebuild this solid geometry from STEP that includes defect handling and curvature rebuilding.

STL vs STEP Comparison

STL file structure: Triangles

STL files are simply lists of triangles: raw, minimal information to approximate a shape.

solid Mesh
  facet normal 0.5 0.5 -0.707107
    outer loop
      vertex -5.20417e-15 17.9605 0
      vertex 17.9605 6.07153e-15 0
      vertex -6.93889e-15 3.46945e-15 -12.7
    endloop
  endfacet
  facet normal -0.5 0.5 0.707107
    outer loop
      vertex -17.9605 4.33681e-15 0
      vertex -3.46945e-15 6.93889e-15 12.7
      vertex -5.20417e-15 17.9605 0
    endloop
  endfacet
  facet normal -0.5 0.5 -0.707107
    outer loop
      vertex -17.9605 4.33681e-15 0
      vertex -5.20417e-15 17.9605 0
      vertex -6.93889e-15 3.46945e-15 -12.7
    endloop
  endfacet
endsolid Mesh

You can see how this raw geometric information would be enough to 3d print a part, but not right to adjust the mug handle or simulate it's strength.

STL vs STEP Comparison

Adjacency and Coplanarity: Faces

Given those points, and triangle normal vectors, we need to convert these triangles into solid boundary geometry.

To do that, we search triangles for those that are adjacent (share an edge) and coplanar (normal directions equal, within tolerance).

If triangles meet this criteria, we merge them, and ultimately build robust 2d shapes from their outlines.

STL vs STEP Comparison

Tessellation: Building curvature

STL files do not store curvature information. Thankfully, using common creation algorithms, we can reverse engineer them.

Generally, parts that have a 25-gon (or similar), are very likely to be circles, especially if they can be built tangent to existing faces or create through holes.

When we see patterns that those 25-gons have the same area and incremental angle, after merging triangles and within reasonable tolerances, we can assume that the design intent is rounded faces. By analyzing the total angle and identifying patterns in the points involved, we can build robust curvature that blends with adjacent faces for ultimately watertight geometry.

STL vs STEP Comparison

STEP File Structure

STEP files are standardized in their hierarchical structure, almost like a Table of Contents, which made it straightforward to build and validate robust geometry. STEP files are built from:

CLOSED_SHELLs (including units/tolerances/metadata)
ADVANCED_FACES
 PLANEs
  AXIS(s)
   DIRECTIONs
 FACE_BOUNDs
  EDGE_LOOPs
   ORIENTED_EDGEs
    LINEs
     VERTEX_POINTs
      CARTESIAN_POINTs

Given this structure, once we understood the desired geometry, it was straightforward to build manifold geometry.

STL vs STEP Comparison

Programming, Hosting, Gaps, and Lessons Learned

After writing the code in Python, with the help of Numpy and Pygame (for STL visualization), we needed to host it.

  • The first step was building an AWS Lambda Function for computing power to handle the conversion. Here I learned the importance of O(n) time complexity, at scale, and needed to restructure some key functions (or pay the price in student AWS credits).
  • The Lambda function needed two S3 buckets, one to POST the files for conversion and one to GET the files back to the user. Of course, the files are encrypted, and deleted immediately once converted.
  • Lastly, a simple AWS Amplify frontend was built to host the process and share how it works.

The code does not work perfectly nor universally. Different STL export algorithms run through different processes, and leave random artifacts that I could not catalog let alone incorporate or assign computing power to catch.

The code could be further improved to handle more complex curvature, guess units based on values (a feature at 25.4 is probably an indicator of mm/in file size), and have better error visualization/validation.

User Upload
User Uploads STL
POST
POST to S3 Bucket
GET
GET from S3 Bucket
Export
Export Your STEP
S3
S3 Uploads Bucket
Lambda
Lambda Cloud Computing
S3
S3 Downloads Bucket