precise-simulation / mesh-viewer

Python STL/OBJ CAD mesh viewers comparing Matplotlib/Plotly/Vispy backends and Tkinter GUI

Home Page:https://www.precisesimulation.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error loading STL file

nicoguaro opened this issue · comments

I tried to load an STL chess knight but it throws the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "meshviewer.py", line 274, in open
    self.model.load_file(file_name)
  File "meshviewer.py", line 46, in load_file
    self.data.append(mesh)
UnboundLocalError: local variable 'mesh' referenced before assignment

The chess knight model seems to be in binary STL format, while the basic load_stl function implementation just parses ASCII. You can quite easily add the numpy-stl library which also supports binary STL format. Please look at the matplotlib example in the corresponding readme.

Thanks for your reply. I think that adding that it works only for ASCII files in the README would help.