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
605 stars 103 forks source link

some part of code did not considered capitalized keywords when loading ascii #154

Closed jimmy-academia closed 3 years ago

jimmy-academia commented 3 years ago

It is common for .stl files to be written with all caps, e.g.

SOLID DEFORM-3D STL FILE                                                        
 FACET NORMAL -0.419229 -0.622622 0.660748
  OUTER LOOP
   VERTEX -3218.33 -20.6627 29.9601
   VERTEX -3214.7 -19.5093 33.3514
   VERTEX -3217.93 -15.7603 34.8369
  ENDLOOP
 ENDFACET
 FACET NORMAL -0.351948 -0.590631 0.726146
  OUTER LOOP
   VERTEX -3214.7 -19.5093 33.3514
   VERTEX -3212.73 -16.1607 37.0293
   VERTEX -3217.93 -15.7603 34.8369
  ENDLOOP
 ENDFACET
...

in stl.py, this causes assertion error around line 200, under _ascii_reader(). Can be fixed by adding .lower() for the following lines:

assert get().lower() == b('outer loop') 
assert get().lower() == b('endloop')
assert get().lower() == b('endfacet')
wolph commented 3 years ago

You are correct, that's an edge case that's not been covered yet. Most parts should already work due to the line = raw_line.lower() on line 161: https://github.com/WoLpH/numpy-stl/blob/6f2b6f831f3e372878fb2d19bbfe6c029a2001aa/stl/stl.py#L161

Thank you for reporting! The new release is online