Description of Issue
When trying to import an STL file with the STL Importer, it fails and reports a Runtime Error!.
Most likely the STL file is too large. Because the importer is designed to slice up the model and allow for multiple undo’s, the memory allotment only allows for models under a certain size. Preferably under 50MB, but up to 100MB on computers with enough memory. Fortunately there is a way to reduce those models that are too large.
The 3D printing world also uses STL files and deal with this exact same issue. These instructions are excerpted from an article on shapeways.com.
Polygon Reduction with Meshlab
There’s a limit to the complexity of objects that you can upload to Shapeways: they can have no more than 1 million polygons. More polygons than that quickly become too much work for our servers and printers to handle.
Some tools like ZBrush can quickly create a high polycount, so its easy to run into this limit. Fortunately there’s a solution known as polygon reduction (also known as mesh decimation). Chances are that your 3D application already has this built-in, otherwise the open source tool MeshLab offers an excellent alternative. MeshLab is available for Windows, OSX and Linux.
The picture below shows the results of a test I did with a small toy car model that had 480,000 faces. Down to 120,000 faces, the difference in quality is hardly noticeable. Below that, you’ll see the model becoming rougher and rougher (click on the image to see the high-res version):
Let’s get started!
If you haven’t already done so, please download and install MeshLab and import your model.
From the menu, select Filters > Remeshing, simplification and construction > Quadratic Edge Collapse Detection. If your model is textured, there is also an option (with texture) that will do a good job at keeping your textures positioned properly. A panel with a few options will show up. You can click on the ‘Help’ button to get extra information about the available options, but that didn’t answer all my questions so I checked with the creator of MeshLab, Peolo Cignoni.
Here are the option settings we believe to be optimal:
Target number of faces – Self explanatory
Quality threshold: 1. Enter a value between 0 and 1 here; the higher the value the harder MeshLab tries to stick to your original model’s shape. The documentation isn’t clear on what the consequence of using a higher value is – my impression is that it’s slightly slower than low values, so I happily used a value of 1 with great results.
Paolo’s comment: ‘Quality threshold affects the simplification penalizing bad shaped faces. To approximate accurately the original shape only with well shaped triangles you require a higher number of faces with respect to allowing more freedom in the final triangle shape. The value is in the range [0..1]: 0 accept any kind of face (no penalties), 0.5 penalize faces with quality < 0.5, proportionally to their shape”.
Preserve Boundary of the Mesh: Yes. Paolo’s comment: ‘The simplification process tries not to destroy mesh boundaries, e.g. exposed edges of the mesh are left untouched. This parameter has no effect on watertight meshes.’
Preserve Normal: Yes. Select this to stop MeshLab from accidentally flipping the face normals. Paolo’s comment: ‘Try to avoid face flipping effects and try to preserve the original orientation of the surface. The only drawback of enabling it is a slight increase in the processing times. On by default.’
If you DO run into inverted normals issues when uploading, try reorienting the normals with the option Filter > Normals, Curvature and Orientation > Re-Orient all faces coherently (note that this will only work for manifold objects).
Optimal position of simplified vertices: Yes. Paolo’s comment: ‘When collapsing an edge the chosen vertex position minimizes the current estimated error. If disabled, the edges are collapsed onto one of the two vertices and the vertices of the final mesh are a subset of the original mesh. It’s on by default.’
Planar simplification: Yes. Paolo’s comment: ‘Add additional simplification constraints that try to preserve the current shape of the triangles. It can greatly improve the quality of the shape of the final triangles on perfectly planar portions of the mesh. Like the quality threshold it affects the accuracy/complexity ratio. Off by default because it is very useful only in particular situations like when you have perfectly flat areas finely tessellated.’’