{"library":"numpy-stl","title":"numpy-stl","description":"Numpy-stl is a Python library designed to simplify reading, writing, and modifying both binary and ASCII STL (stereolithography) files. Leveraging NumPy, it offers fast and efficient operations for 3D object manipulation. The library is currently at version 3.2.0, with regular updates that include bug fixes, new features, and compatibility enhancements for its core dependencies.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install numpy-stl"],"cli":null},"imports":["from stl import mesh","import numpy as np"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import numpy as np\nfrom stl import mesh\nimport os\n\n# --- Create a new mesh from scratch ---\n\n# Define the 8 vertices of the cube\nvertices = np.array([\n    [-1, -1, -1], [+1, -1, -1], [+1, +1, -1], [-1, +1, -1], # Bottom square\n    [-1, -1, +1], [+1, -1, +1], [+1, +1, +1], [-1, +1, +1]  # Top square\n])\n\n# Define the 12 triangles (faces) composing the cube\nfaces = np.array([\n    [0,3,1], [1,3,2], # Bottom\n    [0,4,7], [0,7,3], # Front-left\n    [4,5,6], [4,6,7], # Top\n    [5,1,2], [5,2,6], # Back-right\n    [2,3,6], [3,7,6], # Top-right\n    [0,1,5], [0,5,4]  # Bottom-left\n])\n\n# Create the mesh object\ncube = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))\nfor i, f in enumerate(faces):\n    for j in range(3):\n        cube.vectors[i][j] = vertices[f[j],:]\n\n# Save the mesh to a file\noutput_filename = 'new_cube.stl'\ncube.save(output_filename)\nprint(f\"Saved new mesh to {output_filename}\")\n\n# --- Load an existing STL file ---\n# Create a dummy file for demonstration if it doesn't exist\nif not os.path.exists('example.stl'):\n    # In a real scenario, 'example.stl' would be an existing file.\n    # For this quickstart, we'll save the cube we just created as 'example.stl'\n    # just to demonstrate loading.\n    cube.save('example.stl')\n\ntry:\n    your_mesh = mesh.Mesh.from_file('example.stl')\n    print(f\"Successfully loaded mesh from example.stl with {len(your_mesh.vectors)} triangles.\")\n    # Access mesh properties\n    print(f\"Volume: {your_mesh.get_mass_properties()[0]:.2f}\")\nexcept Exception as e:\n    print(f\"Could not load example.stl: {e}\")","lang":"python","description":"This quickstart demonstrates how to create a simple cube mesh from vertices and faces and save it to an STL file. It also shows how to load an existing STL file and access some of its properties like the number of triangles and volume. The example includes creating a dummy file if one doesn't exist to ensure the loading part is runnable.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"3.2.0","pypi_latest":"3.2.0","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3.8,"avg_import_s":0.53,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.4,"mem_mb":14.9,"disk_size":"90.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.7,"import_time_s":0.32,"mem_mb":14.9,"disk_size":"86M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.56,"mem_mb":16.1,"disk_size":"97.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.7,"import_time_s":0.51,"mem_mb":16.1,"disk_size":"93M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.71,"mem_mb":16.2,"disk_size":"86.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.5,"import_time_s":0.75,"mem_mb":16.2,"disk_size":"82M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.66,"mem_mb":16.2,"disk_size":"85.6M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.7,"import_time_s":0.68,"mem_mb":16.2,"disk_size":"81M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.38,"mem_mb":14.1,"disk_size":"97.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"numpy-stl","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.5,"import_time_s":0.38,"mem_mb":14.1,"disk_size":"96M"}]}}