STL (file format) explained

STL
Extension:.stl
Mime:
  • model/stl[1] [2]
  • model/x.stl-ascii
  • model/x.stl-binary
Owner:3D Systems
Released:1987
Genre:Stereolithography

STL is a file format native to the stereolithography CAD software created by 3D Systems. Chuck Hull, the inventor of stereolithography and 3D Systems’ founder, reports that the file extension is an abbreviation for stereolithography.[3]

An STL file describes a raw, unstructured triangulated surface by the unit normal and vertices (ordered by the right-hand rule[2]) of the triangles using a three-dimensional Cartesian coordinate system.[4] In the original specification, all STL coordinates were required to be positive numbers, but this restriction is no longer enforced and negative coordinates are commonly encountered in STL files today. STL files contain no scale information, and the units are arbitrary.[5] STL files describe only the surface geometry of a three-dimensional object without any representation of color, texture or other common CAD model attributes. The STL format specifies both ASCII and binary representations. Binary files are more common, since they are more compact.[6]

STL is widely used for rapid prototyping, 3D printing and computer-aided manufacturing, and supported by many other software packages.

History

STL was invented by the Albert Consulting Group for 3D Systems in 1987.[7] The format was developed for 3D Systems' first commercial 3D printers. Since its initial release, the format remained relatively unchanged for 22 years.

In 2009, an update to the format, dubbed STL 2.0, was proposed which evolved into the Additive manufacturing file format.[8] [9]

Format

ASCII

An ASCII STL file begins with the line:

solid name

where name is an optional string (though if name is omitted there must still be a space after solid, for compatibility with some software). The remainder of the line is ignored and is sometimes used to store metadata (e.g., filename, author, modification date, etc).[10] The file continues with any number of triangles, each represented as follows:[11]

facet normal ni nj nk outer loop vertex v1x v1y v1z vertex v2x v2y v2z vertex v3x v3y v3z endloop endfacet

where each n or v is a floating-point number in sign-mantissa-e-sign-exponent format, e.g., 2.648000e-002. The file concludes with:

endsolid name

The structure of the format suggests that other possibilities exist (e.g., facets with more than one loop, or loops with more than three vertices). In practice, however, all facets are simple triangles.

Whitespace (spaces, tabs, newlines) may be used anywhere in the file except within numbers or words. The spaces between facet and normal and between outer and loop are required.[6]

Binary

Because ASCII STL files can be very large, a binary version of STL exists. A binary STL file has an 80-character header which is generally ignored, but should never begin with the ASCII representation of the string solid, as that may lead some software to confuse it with an ASCII STL file. Following the header is a 4-byte little-endian unsigned integer indicating the number of triangular facets in the file. Following that is data describing each triangle in turn. The file simply ends after the last triangle.

Each triangle is described by 12 32-bit floating-point numbers: 3 for the normal and then 3 for the X/Y/Z coordinate of each vertex – just as with the ASCII version of STL. After these follows a 2-byte ("short") unsigned integer that is the "attribute byte count" – in the standard format, this should be zero because most software does not understand anything else.[6]

Floating-point numbers are represented as IEEE floating-point numbers and are assumed to be little-endian, although this is not stated in documentation.

UINT8[80] – Header - 80 bytes UINT32 – Number of triangles - 4 bytes

foreach triangle - 50 bytes: REAL32[3] – Normal vector - 12 bytes REAL32[3] – Vertex 1 - 12 bytes REAL32[3] – Vertex 2 - 12 bytes REAL32[3] – Vertex 3 - 12 bytes UINT16 – Attribute byte count - 2 bytes end

There are at least two non-standard variations on the binary STL format for adding color information:

The red/green/blue ordering within those two bytes is reversed in these two approaches – so while these formats could easily have been compatible, the reversal of the order of the colors means that they are not – and worse still, a generic STL file reader cannot automatically distinguish between them. There is also no way to have facets be selectively transparent because there is no per-facet alpha value – although in the context of current rapid prototyping machinery, this is not important.

Facet normal

In both ASCII and binary versions of STL, the facet normal should be a unit vector pointing outwards from the solid object.[12] In most software this may be set to (0,0,0), and the software will automatically calculate a normal based on the order of the triangle vertices using the "right-hand rule", i.e. the vertices are listed in counter-clock-wise order from outside. Some STL loaders (e.g. the STL plugin for Art of Illusion) check that the normal in the file agrees with the normal they calculate using the right-hand rule and warn the user when it does not. Other software may ignore the facet normal entirely and use only the right-hand rule. Although it is rare to specify a normal that cannot be calculated using the right-hand rule, in order to be entirely portable, a file should both provide the facet normal and order the vertices appropriately. A notable exception is SolidWorks, which uses the normal for shading effects.

Characteristics

It is not possible to use triangles to perfectly represent curved surfaces. To compensate, users often save enormous STL files to reduce the inaccuracy. However, native formats associated with many 3D design applications use mathematical surfaces to preserve detail losslessly in small files. For example, Rhino 3D[13] and Blender[14] implement NURBS to create true curved surfaces and store them in their respective native file formats, but must generate a triangle mesh when exporting a model to the STL format.

3D printing

3D printers build objects by solidifying (SLA, SLS, SHS, DMLS, EBM, DLP) or printing (3DP, MJM, FDM, FFF, PJP, MJS)[15] one layer at a time. This requires a series of closed 2D contours (horizontal layers) that are filled in with solidified material as the layers are fused together. A natural file format for such a machine would be a series of closed polygons (layers or slices) corresponding to different Z-values. However, since it is possible to vary the layer thicknesses for a faster though less precise build, it was easier to define the model to be built as a closed polyhedron that can be sliced at the necessary horizontal levels. An incorrect facet normal can affect the way a file is sliced and filled. A slice at a different Z-value can be chosen to miss a bad facet or the file must be returned to CAD program to make corrections and then regenerate the STL file.

To properly form a 3D volume, the surface represented by any STL files must be closed (no holes or reversed vector normal) and connected, where every edge is part of exactly two triangles, and not self-intersecting. Since the STL syntax does not enforce this property, it can be ignored for applications where the void does not matter. The missing surface only matters insofar as the software that slices the triangles requires it to ensure that the resulting 2D polygons are closed. Sometimes such software can be written to clean up small discrepancies by moving vertices that are close together so that they coincide. The results are not predictable, and may require repair using another program. Vector 3D printers require a clean STL file and printing a bad data file will either fail to fill or may stop printing.

Other fields

STL is simple and easy to output. Consequently, many computer-aided design systems can output the STL file format. Although the output is simple to produce, mesh connectivity information is discarded because the identity of shared vertices is lost.

Many computer-aided manufacturing systems require triangulated models. STL format is not the most memory- and computationally efficient method for transferring this data, but STL is often used to import the triangulated geometry into the CAM system. The format is commonly available, so the CAM system will use it. In order to use the data, the CAM system may have to reconstruct the connectivity. As STL files do not save the physical dimension of a unit, a CAM system will ask for it. Typical units are mm and inch.

STL can also be used for interchanging data between CAD/CAM systems and computational environments such as Mathematica.

External links

Notes and References

  1. Web site: model/stl . . iana.org . Allan . Noordvyk . 2018-03-06 . 2022-05-30 .
  2. Web site: STL (STereoLithography) File Format Family . Library of Congress . 2022-05-30 .
  3. Book: Grimm, Todd . User's Guide to Rapid Prototyping . https://books.google.com/books?id=o2B7OmABPNUC&pg=PA55 . 55 . 3. The Rapid Prototyping Process . . 2004 . 0-87263-697-6 .
  4. Web site: STLA Files - ASCII stereolithography files . John . Burkardt . 2014-07-10 . 2022-05-30 .
  5. Web site: The StL Format: Standard Data Format for Fabbers . fabbers.com — Historical resource on 3D printing . 2022-05-30 .
  6. Book: Burns, Marshall . Automated Fabrication: Improving Productivity in Manufacturing . 1993 . . 6.5 . 9780131194625 . 634954895 .
  7. Web site: STL File Format for 3D Printing - Explained in Simple Terms . All3DP . 2017-05-05 . 2016-11-17 .
  8. Web site: STL 2.0 May Replace Old, Limited File Format . RapidToday . 2017-05-05 .
  9. Hiller . Jonathan D. . Lipson . Hod . STL 2.0: A Proposal for a Universal Multi-Material Additive Manufacturing File Format . Cornell University . 2017-05-05 . 2009 . https://web.archive.org/web/20200611234339/https://sffsymposium.engr.utexas.edu/Manuscripts/2009/2009-23-Hiller.pdf . 2020-06-11 . Solid Freeform Fabrication Symposium (SFF'09) . Austin, Texas, USA .
  10. Web site: STL format . Paul . Bourke . October 1999 .
  11. Web site: STL (STereoLithography) File Format, ASCII . Library of Congress . 2022-05-30 .
  12. Book: Peddie, Jon . The History of Visual Magic in Computers: How Beautiful Images are Made in CAD, 3D, VR and AR . Springer . 2013 . 9781447149323 . London, England . 54–57 . 849634980 .
  13. Web site: What are NURBS? . 2021-06-25 . www.rhino3d.com . en .
  14. Web site: Structure — Blender Manual . 2021-06-25 . docs.blender.org .
  15. Book: Barnatt, Christopher . 3D Printing: The Next Industrial Revolution . ExplainingTheFuture.com . Nottingham, England . 2013 . 9781484181768 . 26–71 . 854672031 .