Skip to content

Commit

Permalink
fix stl newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedh committed Jan 31, 2024
1 parent 8510ef2 commit 628c8e3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions trimesh/exchange/stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,24 @@ def export_stl_ascii(mesh) -> str:
blob[:, 1:, :] = mesh.triangles

# create a lengthy format string for the data section of the file
formatter = "\n".join(
[
"facet normal {} {} {}\nouter loop",
"vertex {} {} {}\n" * 3,
"endloop",
"endfacet",
]
formatter = (
"\n".join(
[
"facet normal {} {} {}",
"outer loop",
"vertex {} {} {}\nvertex {} {} {}\nvertex {} {} {}",
"endloop",
"endfacet",
"",
]
)
) * len(mesh.faces)

# try applying the name from metadata if it exists
name = mesh.metadata.get("name", "")
if not isinstance(name, str):
name = ""
if len(name) > 80:
if len(name) > 80 or "\n" in name:
name = ""

# concatenate the header, data, and footer, and a new line
Expand Down

0 comments on commit 628c8e3

Please sign in to comment.