Skip to content

Commit

Permalink
Fixed the write to ascii by manually converting to floats instead of …
Browse files Browse the repository at this point in the history
…np.float, making it readable by other softwares
  • Loading branch information
JBil8 committed Nov 1, 2024
1 parent c7c4683 commit fc716e3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions stl/stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,14 @@ def p(s, file):
p('solid %s' % name, file=fh)

for row in self.data:
# Explicitly convert each component to standard float for normals and vertices
normals = tuple(float(n) for n in row['normals'])
vectors = row['vectors']
p('facet normal %r %r %r' % tuple(row['normals'].tolist()), file=fh)
p('facet normal %f %f %f' % normals, file=fh)
p(' outer loop', file=fh)
p(' vertex %r %r %r' % tuple(vectors[0].tolist()), file=fh)
p(' vertex %r %r %r' % tuple(vectors[1].tolist()), file=fh)
p(' vertex %r %r %r' % tuple(vectors[2].tolist()), file=fh)
p(' vertex %f %f %f' % tuple(float(v) for v in vectors[0]), file=fh)
p(' vertex %f %f %f' % tuple(float(v) for v in vectors[1]), file=fh)
p(' vertex %f %f %f' % tuple(float(v) for v in vectors[2]), file=fh)
p(' endloop', file=fh)
p('endfacet', file=fh)

Expand Down

0 comments on commit fc716e3

Please sign in to comment.