Skip to main content

A Streamlit component to display 3D models in STL format

Project description

Streamlit STL Display Component

A Streamlit component to display STL files.

Installation

This component requires access to write files to the temporary directory.

pip install streamlit_stl

Example

Alt Text

Look at the example for a streamlit Web App:

Streamlit App

The original STL file is from Printables.

Usage

Display from file paths

import streamlit as st
from streamlit_stl import stl_from_file

success = stl_from_file(
    file_path=path_to_conf,          # Path to the STL file
    color='#FF9900',                 # Color of the STL file (hexadecimal value)
    material='material',             # Material of the STL file ('material', 'flat', or 'wireframe')
    auto_rotate=True,                # Enable auto-rotation of the STL model
    opacity=1,                       # Opacity of the STL model (0 to 1)
    shininess=100,                   # How shiny the specular highlight is, when using the 'material' style.
    cam_v_angle=60,                  # Vertical angle (in degrees) of the camera
    cam_h_angle=-90,                 # Horizontal angle (in degrees) of the camera
    cam_distance=None,               # Distance of the camera from the object (defaults to 3x bounding box size)
    height=500,                      # Height of the viewer frame
    max_view_distance=1000,          # Maximum viewing distance for the camera
    key=None                         # Streamlit component key
)

Display from file text

import streamlit as st
from streamlit_stl import stl_from_text

file_input = st.file_uploader("Or upload an STL file", type=["stl"])

if file_input is not None:
    success = stl_from_text(
        text=file_input.getvalue(),  # Content of the STL file as text
        color='#FF9900',             # Color of the STL file (hexadecimal value)
        material='material',         # Material of the STL file ('material', 'flat', or 'wireframe')
        auto_rotate=True,            # Enable auto-rotation of the STL model
        opacity=1,                   # Opacity of the STL model (0 to 1)
        shininess=100,               # How shiny the specular highlight is, when using the 'material' style.
        cam_v_angle=60,              # Vertical angle (in degrees) of the camera
        cam_h_angle=-90,             # Horizontal angle (in degrees) of the camera
        cam_distance=None,           # Distance of the camera from the object (defaults to 3x bounding box size)
        height=500,                  # Height of the viewer frame
        max_view_distance=1000,      # Maximum viewing distance for the camera
        key=None                     # Streamlit component key
    )

The functions return a boolean value indicating if the program was able to write and read the files.

The 'material' style is the default style, it uses the Phong shading model from Three.js.

License

Code is licensed under the GNU General Public License v3.0 (GPL-3.0)

License: GPL-3.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_stl-0.0.5.tar.gz (182.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_stl-0.0.5-py3-none-any.whl (184.0 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_stl-0.0.5.tar.gz.

File metadata

  • Download URL: streamlit_stl-0.0.5.tar.gz
  • Upload date:
  • Size: 182.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for streamlit_stl-0.0.5.tar.gz
Algorithm Hash digest
SHA256 17000645920e92fe4731d7d9bc1622f16f6c95e863ba6f05c63f45427408c87d
MD5 6216c03f3159f2f5743ad75da7030160
BLAKE2b-256 b8aad647de1ac5d4f7eba562c0e981e0d54d765ee69a6d736c583a866fac26fb

See more details on using hashes here.

File details

Details for the file streamlit_stl-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: streamlit_stl-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 184.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for streamlit_stl-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a9d46766bd5519da8a6953efcd9bb874a21b6ab3c0af1e75feab4e04d4e47e3b
MD5 ee1dc4f28f6eb171e936ec449635497f
BLAKE2b-256 f1c095e80670a031ad2fbaf7d3011a2cec5ff37ed6e3e2dd5eb85296984f87ad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page