nschloe / meshio

:spider_web: input/output for many mesh formats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Writing STL to buffer fails

wayofsamu opened this issue · comments

Hey,

Thank you for your awesome tool.
A small bug occurred, when I tried to write a stl file to buffer.

--> [254](https://file+.vscode-resource.vscode-cdn.net/run/media/samuels/Volume/TracOptic%20Progress/UNOTT_CSI/venv310/lib/python3.10/site-packages/meshio/stl/_stl.py:254) a.tofile(fh)

UnsupportedOperation: fileno

I would change

a.tofile(fh)

to

if is_buffer(filename, "wb"):
    fh.write(a.tobytes())
else:
    a.tofile(fh)