Spaces:
Runtime error
Runtime error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files1234345678891011 unmodified lines22232426272829252631323334352728293031323334353637383940import streamlit as stimport numpy as npimport pyvista as pvfrom stl import meshfrom mpl_toolkits import mplot3dimport matplotlib.pyplot as pltimport tempfileimport osimport trimeshimport pyvista as pv
# Page configurationst.set_page_config(page_title="AR CAD Viewer", layout="wide")11 unmodified lines temp_file.write(uploaded_file.read()) temp_filepath = temp_file.name
# Load the STL file stl_mesh = mesh.Mesh.from_file(temp_filepath)
# Preview the model in 3D # Load the STL file using pyvista for interactive 3D rendering st.subheader("3D Model Preview") fig = plt.figure(figsize=(10, 10)) ax = fig.add_subplot(111, projection="3d") ax.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors, alpha=0.7, color="cyan")) ax.auto_scale_xyz(stl_mesh.points.flatten(), stl_mesh.points.flatten(), stl_mesh.points.flatten()) st.pyplot(fig) # Load the STL using pyvista mesh_data = pv.read(temp_filepath) # Create the plotter and add the mesh to it plotter = pv.Plotter(off_screen=True) plotter.add_mesh(mesh_data, color="cyan") plotter.view_isometric() # Show the plot in the Streamlit app st.pydeck_chart(plotter.show())
# Convert to glTF for AR st.subheader("Convert to AR Format")app.py+14-12