tessl install tessl/pypi-numpy-stl@3.2.0Library to make reading, writing and modifying both binary and ascii STL files easy.
Agent Success
Agent success rate when using this tile
85%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.39x
Baseline
Agent success rate without this tile
61%
A small utility for loading STL files with automatic ASCII/BINARY detection, exporting them in a requested format, and optionally disabling performance speedups.
detected_format as "ascii" and provides the triangle count from the file contents. @testdetected_format as "binary" and provides the triangle count from the file contents. @testformat_hint="ascii" writes ASCII output even when the input was binary. @testformat_hint="binary" writes binary output even when the input was ASCII. @testuse_speedups=False still loads and saves meshes successfully and reports speedups_enabled as False in the load result. @test@generates
from typing import Any, Dict, Literal
class STLConverter:
def __init__(self, use_speedups: bool = True) -> None:
"""Store whether performance speedups should be used when loading and saving."""
def load(self, source_path: str) -> Dict[str, Any]:
"""
Read an STL file with automatic ASCII/BINARY detection and return:
- "mesh": mesh handle from the dependency
- "triangle_count": triangle count as int
- "detected_format": "ascii" or "binary"
- "speedups_enabled": whether speedups were used
"""
def save(self, mesh_obj: Any, target_path: str, format_hint: Literal["auto", "ascii", "binary"] = "auto") -> None:
"""
Write the mesh to target_path, using ASCII/BINARY according to format_hint.
When format_hint is "auto", preserve the detected_format from the last load.
"""Python library for reading and writing STL meshes with automatic ASCII/BINARY handling and optional Cython speedups. @satisfied-by