lyunm1206
commited on
Commit
·
bb23c61
1
Parent(s):
b954b38
obj
Browse files- app.py +9 -36
- obj1.obj +0 -0
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -1,37 +1,10 @@
|
|
| 1 |
-
import shutil
|
| 2 |
import streamlit as st
|
| 3 |
-
import
|
| 4 |
-
from
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
# save the uploaded file to disk
|
| 13 |
-
with open("stlfile.stl", "wb") as buffer:
|
| 14 |
-
shutil.copyfileobj(file, buffer)
|
| 15 |
-
|
| 16 |
-
# Create a new plot
|
| 17 |
-
figure = pyplot.figure()
|
| 18 |
-
axes = figure.add_subplot(projection='3d')
|
| 19 |
-
|
| 20 |
-
# Load the STL files and add the vectors to the plot
|
| 21 |
-
|
| 22 |
-
mesh = stl.mesh.Mesh.from_file("stlfile.stl")
|
| 23 |
-
|
| 24 |
-
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(mesh.vectors, color='lightgrey'))
|
| 25 |
-
#axes.plot_surface(mesh.x,mesh.y,mesh.z)
|
| 26 |
-
# Auto scale to the mesh size
|
| 27 |
-
scale = mesh.points.flatten()
|
| 28 |
-
axes.auto_scale_xyz(scale, scale, scale)
|
| 29 |
-
|
| 30 |
-
#turn off grid and axis from display
|
| 31 |
-
pyplot.axis('off')
|
| 32 |
-
|
| 33 |
-
#set viewing angle
|
| 34 |
-
axes.view_init(azim=120)
|
| 35 |
-
|
| 36 |
-
# Show the plot to the screen
|
| 37 |
-
st.pyplot(figure)
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import streamlit.components.v1 as components
|
| 3 |
+
from obj2html import obj2html
|
| 4 |
+
|
| 5 |
+
# run in the root folder, not inside exaples, to have the relative path working
|
| 6 |
+
obj_path = "obj1.obj"
|
| 7 |
+
html_string = obj2html(obj_path, html_elements_only=True)
|
| 8 |
+
components.html(html_string)
|
| 9 |
+
with open(obj_path) as f:
|
| 10 |
+
st.download_button('Download model.obj', f, file_name="model.obj")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj1.obj
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
requirements.txt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
pyvista
|
| 2 |
stpyvista
|
| 3 |
matplotlib
|
| 4 |
-
|
| 5 |
numpy-stl
|
|
|
|
| 1 |
pyvista
|
| 2 |
stpyvista
|
| 3 |
matplotlib
|
| 4 |
+
obj2html
|
| 5 |
numpy-stl
|