From fc716e3abb0403a6c00a653dcac5390d4ba47b0b Mon Sep 17 00:00:00 2001 From: JBil8 Date: Fri, 1 Nov 2024 11:06:59 +0100 Subject: [PATCH] Fixed the write to ascii by manually converting to floats instead of np.float, making it readable by other softwares --- stl/stl.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stl/stl.py b/stl/stl.py index b6bcd2d..51beac2 100644 --- a/stl/stl.py +++ b/stl/stl.py @@ -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)