Spaces:
Runtime error
Runtime error
SHAMIL SHAHBAZ AWAN commited on
Update app.py
Browse files123456789101111 unmodified lines23242526272829303132333435363738import streamlit as stfrom 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 linestemp_file.write(uploaded_file.read())temp_filepath = temp_file.name# Load the STL filestl_mesh = mesh.Mesh.from_file(temp_filepath)# Preview the model in 3Dst.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)# Convert to glTF for ARst.subheader("Convert to AR Format")1234567891011 unmodified lines22232425262728293031323334353637383940import streamlit as stimport numpy as npimport pyvista as pvfrom stl import meshimport tempfileimport osimport trimesh# Page configurationst.set_page_config(page_title="AR CAD Viewer", layout="wide")11 unmodified linestemp_file.write(uploaded_file.read())temp_filepath = temp_file.name# Load the STL file using pyvista for interactive 3D renderingst.subheader("3D Model Preview")# Load the STL using pyvistamesh_data = pv.read(temp_filepath)# Create the plotter and add the mesh to itplotter = pv.Plotter(off_screen=True)plotter.add_mesh(mesh_data, color="cyan")plotter.view_isometric()# Show the plot in the Streamlit appst.pydeck_chart(plotter.show())# Convert to glTF for ARst.subheader("Convert to AR Format")
app.py+14-12