wolph / numpy-stl

Simple library to make working with STL files (and 3D objects in general) fast and easy.
http://numpy-stl.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
624 stars 105 forks source link

File too large, got x triangles which exceeds the maximum of 100000000 #143

Closed superzaki closed 4 years ago

superzaki commented 4 years ago

As the titles suggests, when I try to load an .stl file with size 73.5 MB (77,130,069 bytes), I get this error: AssertionError: File too large, got 171520558 triangles which exceeds the maximum of 100000000 I thought I could make some tweaks in "stl.py" to cope with the large files that I have, but I ended up with more errors; most notably, I made changes in: #: The maximum amount of triangles we can read from binary files MAX_COUNT = 1e9 And the generated error is: AssertionError: Expected 1542599 vectors but header indicates 171520558

With smaller file sizes, numpy-stl works flawlessly and is certainly faster than most of the other 3D-files-handling py libraries.

wolph commented 4 years ago

Increasing the MAX_COUNT should be enough if your file is actually a binary file. In most cases however, the file is either damaged or an ascii file being read as binary which causes this issue.

Since your file is 77,130,069 bytes it is pretty much impossible that you are actually going over the 100,000,000 triangles. A triangle takes more than a single byte so you've got a different issue.

You can try forcing the file to be read as ascii which might work (if it is actually ascii):

import stl

mesh = stl.Mesh.from_file(filename, mode=stl.Mode.ASCII)

If that doesn't work than I suspect your file is somehow damaged

superzaki commented 4 years ago

You were right @WoLpH . The files I was using were indeed damaged; After using Ideamaker to auto-repair these, numpy-stl manipulated 369 MB worth if stl files within 6 s. Impressive! Thanks again- topic closed.